{"record":{"id":"0a54205b9bf9efd7","repo":"anomalyco/sst","slug":"react-router-server-bundle-not-found-at-serv","errorCode":null,"errorMessage":"React Router server bundle not found at:\n  \"${serverPath}\".\n\nMake sure the Cloudflare Vite plugin is configured in your `vite.config.ts`.\nIf your React Router project is entirely pre-rendered, use `sst.cloudflare.StaticSite` instead.","messagePattern":"React Router server bundle not found at:\n  \"(.+?)\"\\.\n\nMake sure the Cloudflare Vite plugin is configured in your `vite\\.config\\.ts`\\.\nIf your React Router project is entirely pre-rendered, use `sst\\.cloudflare\\.StaticSite` instead\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/cloudflare/react-router.ts","lineNumber":280,"sourceCode":"    super(__pulumiType, name, args, opts);\n  }\n\n  protected validate(sitePath: string): void {\n    validateFrameworkConfig({\n      sitePath,\n      configName: \"vite.config\",\n      componentName: \"ReactRouter\",\n    });\n    validateNoWranglerFile(sitePath, \"ReactRouter\");\n  }\n\n  protected buildPlan(outputPath: Output<string>): Output<Plan> {\n    return outputPath.apply(async (outputPath) => {\n      const serverPath = path.join(outputPath, \"build\", \"server\", \"index.js\");\n      const assetsPath = path.join(outputPath, \"build\", \"client\");\n\n      if (!(await existsAsync(serverPath))) {\n        throw new VisibleError(\n          [\n            `React Router server bundle not found at:\\n  \"${serverPath}\".`,\n            \"\",\n            \"Make sure the Cloudflare Vite plugin is configured in your `vite.config.ts`.\",\n            \"If your React Router project is entirely pre-rendered, use `sst.cloudflare.StaticSite` instead.\",\n          ].join(\"\\n\"),\n        );\n      }\n\n      if (!(await existsAsync(assetsPath))) {\n        throw new VisibleError(\n          `React Router assets directory not found at:\\n  \"${assetsPath}\".`,\n        );\n      }\n\n      return {\n        server: \"./build/server/index.js\",\n        assets: \"./build/client\",","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/cloudflare/react-router.ts#L262-L298","documentation":"After building a React Router (Vite) app, SST expects the server bundle at `build/server/index.js` inside the output directory. If it's missing, SST can't create the Worker and throws with guidance: the Cloudflare Vite plugin likely isn't configured, or the app is fully pre-rendered and should be a StaticSite.","triggerScenarios":"Running `sst deploy` on a React Router project whose build lacks `build/server/index.js`: missing/incorrect `@cloudflare/vite-plugin` in vite.config.ts, wrong `path` in the component args, or a prerender-only build.","commonSituations":"Migrating a React Router SPA from Remix without adding the Cloudflare Vite plugin; running `vite build` instead of the project's ssg/build command; pointing the component at the project root instead of the build output directory.","solutions":["Add `@cloudflare/vite-plugin` to the plugins array in `vite.config.ts` and rebuild","Verify the component's `path` points to the app directory containing `build/` (or the correct output dir)","If the site is entirely pre-rendered, switch to `sst.cloudflare.StaticSite`","Run the project's official build command (not a custom one that skips the server bundle) and confirm `build/server/index.js` exists"],"exampleFix":"// before (vite.config.ts)\nplugins: [reactRouter()]\n// after\nimport { cloudflare } from '@cloudflare/vite-plugin';\nplugins: [reactRouter(), cloudflare()]","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport path from 'path';\nconst out = 'apps/web';\nif (!existsSync(path.join(out, 'build', 'server', 'index.js')))\n  throw new Error('React Router server bundle missing: run vite build with @cloudflare/vite-plugin');\nnew sst.cloudflare.ReactRouter('Site', { path: out });","typeGuard":null,"tryCatchPattern":"// thrown during deploy/synth, catch around stack definition is atypical; detect pre-deploy\ntry {\n  await deploy();\n} catch (e) {\n  if (/React Router server bundle not found/.test(e.message)) console.error('Enable the Cloudflare Vite plugin');\n}","preventionTips":["Always include `@cloudflare/vite-plugin` in vite.config.ts for SSR React Router apps","Build the app before `sst deploy`","Check build/server/index.js exists in CI before deploying","Use StaticSite for fully pre-rendered apps"],"tags":["react-router","cloudflare","build-output","vite"],"backgroundTag":"build-output-not-found","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}