Skip to content

recipes/tanstack

View source on GitHub

typescript
import '@catapultjs/deploy/recipes/tanstack'

This recipe runs the standard Node.js install and build tasks on the server for a TanStack Start application. It does not override deploy:update_code, so combine it with a transfer recipe such as git or rsync.

TanStack Start supports Vite builds through Nitro. For a Node.js server deployment, configure Nitro in vite.config.ts with the node-server preset, then run the generated server output on the target host.

See the example TanStack Start project for a complete setup, or go directly to deploy.ts.

Tasks

TaskInsertedDescription
deploy:installafter deploy:update_codeInstalls dependencies in the release
deploy:buildafter deploy:installRuns the package manager build script

Configuration

KeyTypeDefaultDescription
shared_filesstring[]['.env']Files symlinked from shared/ into each release

Vite + Nitro

Install Nitro:

bash
npm install nitro

Configure vite.config.ts:

typescript
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { nitro } from 'nitro/vite'
import viteReact from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [
    tanstackStart(),
    nitro({ preset: 'node-server' }),
    viteReact(),
  ],
})

Use package scripts that build with Vite and start the Nitro output:

json
{
  "scripts": {
    "build": "vite build",
    "start": "node .output/server/index.mjs"
  }
}

For PM2, use the generated server entry and pass the host/port environment variables explicitly:

javascript
module.exports = {
  apps: [
    {
      name: 'tanstack',
      cwd: '/home/deploy/myapp/current',
      script: '.output/server/index.mjs',
    },
  ],
}

See TanStack's Node.js / Docker hosting guide for the upstream hosting details.