RuntimePackage ManagerBundlerTest RunnerLinterFormatterGuidesReferenceBlogFeedback

Use TanStack Start with Bun

TanStack Start is a full-stack framework powered by TanStack Router and Vite. It supports full-document SSR, streaming, server functions, and bundling.


  1. Create a new TanStack Start app

    Use the interactive CLI to create a new TanStack Start app.

    terminal
    bunx @tanstack/cli create my-tanstack-app
    
  2. Start the dev server

    Change to the project directory and start the Vite dev server with Bun.

    terminal
    cd my-tanstack-app
    bun --bun run dev
    
  3. Update scripts in package.json

    In the scripts field of your package.json, prefix the Vite CLI commands with bun --bun so that Bun runs the Vite CLI for dev, build, and preview.

    package.json
    {
      "scripts": {
        "dev": "bun --bun vite dev", // [!code ++]
        "build": "bun --bun vite build", // [!code ++]
        "preview": "bun --bun vite preview" // [!code ++]
      }
    }
    

Hosting

To host your TanStack Start app in production, use Nitro or a custom Bun server.

  1. Add Nitro to your project

    Add Nitro to your project to deploy your TanStack Start app to different platforms.

    terminal
    bun add nitro
    
  2. Update your vite.config.ts file

    Add the Nitro plugin to your vite.config.ts file.

    vite.config.ts
    // other imports...
    import { nitro } from "nitro/vite"; // [!code ++]
    
    const config = defineConfig({
      plugins: [
        tanstackStart(),
        nitro({ preset: "bun" }), // [!code ++]
        // other plugins...
      ],
    });
    
    export default config;
    
  3. Update the start command

    Make sure build and start scripts are present in your package.json file:

    package.json
      {
        "scripts": {
          "build": "bun --bun vite build", // [!code ++]
          // The .output files are created by Nitro when you run `bun run build`.
          // Not necessary when deploying to Vercel.
          "start": "bun run .output/server/index.mjs" // [!code ++]
        }
      }
    
  4. Deploy your app

    Use one of the following guides to deploy your app to a hosting provider.


Templates


→ See TanStack Start's hosting documentation