Skip to content
For agents
Browse guides

TanStack Start

Run a full-stack React app with a production Node server, including server routes and server functions.

Open Markdown

Deploy a TanStack Start app, with its server routes and server functions, as one Node server.

Build and server

Smolcloud's starter uses Vite and Nitro. npm run build writes the server and public assets to .output; node .output/server/index.mjs starts the production app.

The starter uses @tanstack/react-start 1.168.60 and nitro 3.0.260903-beta; keep its lockfile so you get the same versions. If your own project uses a different adapter, check where it writes its build before using the Dockerfile below.

TypeScript
// vite.config.ts
import { defineConfig } from "vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { nitro } from "nitro/vite";
import react from "@vitejs/plugin-react";
export default defineConfig({ plugins: [tanstackStart(), nitro(), react()] });

Set the build script to vite build and the start script to node .output/server/index.mjs. Add a health route that returns 200 (the starter has /api/health) and set it as the app's health path in Configuration.

Build with a Dockerfile

This Dockerfile uses npm. For pnpm, Yarn or Bun, copy that tool's lockfile instead and change the install line.

Code
FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20 AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20
WORKDIR /app
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
COPY --from=build --chown=10001:10001 /app/.output ./.output
USER 10001:10001
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]

Deploy the app

Save the Dockerfile at the source root. In Configuration, set the port to 3000 and the health path to the route you added above. Add a .dockerignore that excludes .env*, .git, node_modules and local build output, then deploy:

Shell
smolcloud deploy APP_ID .

Open the address it prints. You can also call a route from the CLI:

Shell
smolcloud request APP_ID /

You don't have to write a Dockerfile: see Automatic builds. To add a database or file storage, see Databases and files.

See also: TanStack Node/Docker hosting.