{"record":{"id":"5e3d2ce780ac1ff5","repo":"remix-run/react-router","slug":"react-router-vite-plugin-not-found-in-vite-config","errorCode":null,"errorMessage":"React Router Vite plugin not found in Vite config","messagePattern":"React Router Vite plugin not found in Vite config","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/vite/build.ts","lineNumber":74,"sourceCode":"              },\n            };\n          }\n          if (sourcemapServer && name !== \"client\") {\n            return {\n              build: {\n                sourcemap: sourcemapServer,\n              },\n            };\n          }\n        },\n        configResolved(config) {\n          let hasReactRouterPlugin = config.plugins.find(\n            (plugin) =>\n              plugin.name === \"react-router\" ||\n              plugin.name === \"react-router/rsc\",\n          );\n          if (!hasReactRouterPlugin) {\n            throw new Error(\n              \"React Router Vite plugin not found in Vite config\",\n            );\n          }\n        },\n      },\n    ],\n  });\n  await builder.buildApp();\n}\n","sourceCodeStart":56,"sourceCodeEnd":84,"githubUrl":"https://github.com/remix-run/react-router/blob/6beaca39526d5716c3c112ebb0782765baa5a9ce/packages/react-router-dev/vite/build.ts#L56-L84","documentation":"React Router's build orchestration (`react-router build`) resolves your Vite config and then verifies that the React Router Vite plugin (name `react-router` or `react-router/rsc`) is present in the resolved plugin list. Without that plugin, the framework cannot discover routes, run the SSR/SSG compilers, or inject the virtual modules the app relies on, so the build aborts immediately. It is a fail-fast guard against running the React Router CLI against a plain Vite project.","triggerScenarios":"Running `react-router build` (or calling the build API in packages/react-router-dev/vite/build.ts) when vite.config.ts does not include `reactRouter()` from `@react-router/dev/vite`; the plugin is added conditionally (e.g. only when an env var is set) so it resolves to absent; the plugin is wrapped/renamed by another wrapper so its `name` is no longer `react-router` or `react-router/rsc`.","commonSituations":"Migrating a Vite SPA to React Router Framework Mode but forgetting the plugin; mixing up `vite build` vs `react-router build` in a monorepo script; a config factory that skips the plugin for `mode === 'development'`; upgrading templates where the plugin import moved from `@react-router/dev/vite` to a different package.","solutions":["Add the React Router Vite plugin to vite.config.ts: `import { reactRouter } from '@react-router/dev/vite';` and include `reactRouter()` in the `plugins` array","Verify no conditional logic (env checks, mode checks) removes the plugin from the array used for builds","Confirm the plugin is instantiated exactly once and is not renamed/wrapped by another plugin wrapper","If you intended a plain Vite app, invoke `vite build` instead of `react-router build`"],"exampleFix":"// before (vite.config.ts)\nimport { defineConfig } from 'vite';\nexport default defineConfig({ plugins: [] });\n\n// after\nimport { defineConfig } from 'vite';\nimport { reactRouter } from '@react-router/dev/vite';\nexport default defineConfig({\n  plugins: [reactRouter()],\n});","handlingStrategy":"validation","validationCode":"// vite.config.ts — assert the plugin is present before building\nimport { reactRouter } from '@react-router/dev/vite';\nconst plugins = [reactRouter()];\nif (!plugins.some((p) => p && 'name' in p && (p.name === 'react-router' || p.name === 'react-router/rsc'))) {\n  throw new Error('reactRouter() plugin missing from config');\n}\nexport default defineConfig({ plugins });","typeGuard":"const hasReactRouterPlugin = (plugins: unknown[]): boolean =>\n  plugins.some(\n    (p): p is { name: string } =>\n      !!p &&\n      typeof p === 'object' &&\n      'name' in p &&\n      ((p as { name: unknown }).name === 'react-router' ||\n       (p as { name: unknown }).name === 'react-router/rsc'),\n  );","tryCatchPattern":"try {\n  await exec('react-router build');\n} catch (e) {\n  if (e instanceof Error && /not found in Vite config/.test(e.message)) {\n    failBuild('vite.config.ts must include reactRouter() from @react-router/dev/vite');\n  }\n  throw e;\n}","preventionTips":["Keep `reactRouter()` unconditional at the top of the plugins array in vite.config.ts","Add a CI smoke step that runs `react-router typegen` — it fails fast on a missing plugin","Avoid sharing vite configs between React Router and plain Vite apps"],"tags":["vite","config","build","plugin"],"backgroundTag":"missing-vite-plugin","analyzedSha":"6beaca39526d5716c3c112ebb0782765baa5a9ce","analyzedAt":"2026-08-18T18:04:14.938Z","contentChangedAt":"2026-08-18T18:04:14.938Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}