StartpodDocs

Next.js

Install and run a Next.js project with Startpod.

Startpod includes the browser-compatible compiler and worker support needed by its tested Next.js path. Your host application only installs startpod; the Next.js dependency belongs to the project running inside the pod.

Mount a Next.js project

await startpod.mount({
  "package.json": {
    file: {
      contents: JSON.stringify({
        scripts: { dev: "next dev" },
        dependencies: {
          next: "16.2.7",
          react: "19.2.7",
          "react-dom": "19.2.7",
          typescript: "5.9.3",
          "@types/react": "19.2.18",
          "@types/node": "22.18.6",
        },
      }),
    },
  },
  app: {
    directory: {
      "layout.tsx": {
        file: {
          contents:
            "import type { ReactNode } from 'react'; export default function Layout({ children }: { children: ReactNode }) { return <html><body>{children}</body></html> }",
        },
      },
      "page.tsx": {
        file: {
          contents: "export default function Page() { return <h1>Hello from Next.js</h1> }",
        },
      },
    },
  },
})

Install and start it

const install = await startpod.spawn("npm", ["install"])
if ((await install.exit) !== 0) throw new Error("npm install failed")

await startpod.spawn("npm", ["run", "dev"])

Next.js is a larger compatibility surface than Vite. Use the versions listed in compatibility and test the routes your product depends on before shipping them to users.

Try it in the browser

The TypeScript example starts automatically. Edit page.tsx and watch Next.js update the application beside the editor. The terminal shows its development server output.

Loading editor…

On this page