{"record":{"id":"e0109903e02f2945","repo":"facebook/docusaurus","slug":"invalid-route-config-path-must-be-a-string-and-co","errorCode":null,"errorMessage":"Invalid route config: path must be a string and component is required.\\n${JSON.stringify(routeConfig)}","messagePattern":"Invalid route config: path must be a string and component is required\\.\\\\n(.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus/src/server/codegen/codegenRoutes.ts","lineNumber":217,"sourceCode":"  index: number,\n  level: number,\n): string {\n  const {\n    path: routePath,\n    component,\n    modules = {},\n    context,\n    routes: subroutes,\n    priority,\n    exact,\n    metadata,\n    props,\n    plugin,\n    ...attributes\n  } = routeConfig;\n\n  if (typeof routePath !== 'string' || !component) {\n    throw new Error(\n      `Invalid route config: path must be a string and component is required.\n${JSON.stringify(routeConfig)}`,\n    );\n  }\n\n  // Because 2 routes with the same path could lead to hash collisions\n  // See https://github.com/facebook/docusaurus/issues/10718#issuecomment-2498516394\n  function generateUniqueRouteKey(): {\n    routeKey: string;\n    routeHash: string;\n  } {\n    const hashes = [\n      // // OG algo to keep former snapshots\n      () => simpleHash(JSON.stringify(routeConfig), 3),\n      // Other attempts, not ideal but good enough\n      // Technically we could use Math.random() here but it's annoying for tests\n      () => simpleHash(`${level}${index}`, 3),\n      () => simpleHash(JSON.stringify(routeConfig), 4),","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus/src/server/codegen/codegenRoutes.ts#L199-L235","documentation":"Thrown by `genChunkNames` route processing when a route's `path` is not a string or its `component` is missing. Every route must declare a string path and a React component; otherwise codegen cannot emit the routing modules. The full route object is JSON-serialized into the message for diagnosis.","triggerScenarios":"A plugin's `routes` (or sub-`routes`) array contains an entry where `path` is undefined/non-string, or where `component` is omitted/falsy. Triggered during route codegen at build time.","commonSituations":"Custom plugin returning a route without `component`; versioned docs/plugin emitting a route with `path: undefined` after a refactor; typo in plugin route definition; spread/rest accidentally swallowing `component`.","solutions":["Inspect the serialized route object in the error message to find which plugin emitted it.","Ensure every route object has `component: '@theme/SomeComponent'` (or an alias) and a string `path`.","For sub-routes, confirm parent plugins propagate `component` correctly.","Add a unit test on your plugin's route output asserting `typeof path === 'string' && !!component`."],"exampleFix":"// before (plugin routes)\nexport default {\n  path: '/my-page',\n  // component missing\n  exact: true,\n};\n// after\nexport default {\n  path: '/my-page',\n  component: '@theme/MDXPage',\n  exact: true,\n};","handlingStrategy":"validation","validationCode":"if (typeof routePath !== 'string' || !component) {\n  throw new Error(`Route invalid: ${JSON.stringify(routeConfig)}`);\n}","typeGuard":"function isValidRouteConfig(r: any): r is { path: string; component: string } {\n  return typeof r?.path === 'string' && typeof r?.component === 'string' && !!r.component;\n}","tryCatchPattern":null,"preventionTips":["Validate plugin route output in dev with the type guard above.","Add unit tests asserting every emitted route has `path` and `component`.","Type your plugin's route return as `RouteConfig` to catch missing fields at compile time."],"tags":["routing","codegen","plugins","validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}