{"record":{"id":"59b23f9a050c19e9","repo":"remix-run/react-router","slug":"module-cannot-have-both-an-errorboundary-export-an","errorCode":null,"errorMessage":"Module cannot have both an ErrorBoundary export and a ServerErrorBoundary export","messagePattern":"Module cannot have both an ErrorBoundary export and a ServerErrorBoundary export","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/vite/rsc/virtual-route-config.ts","lineNumber":40,"sourceCode":"    if (\"default\" in mod && mod.default) {\n      if (\"ServerComponent\" in mod && mod.ServerComponent) {\n        throw new Error(\"Module cannot have both a default export and a ServerComponent export\");\n      }\n      Component = mod.default;\n    } else if (\"ServerComponent\" in mod && mod.ServerComponent) {\n      Component = mod.ServerComponent;\n    }\n    if (\"Layout\" in mod && mod.Layout) {\n      if (\"ServerLayout\" in mod && mod.ServerLayout) {\n        throw new Error(\"Module cannot have both a Layout export and a ServerLayout export\");\n      }\n      Layout = mod.Layout;\n    } else if (\"ServerLayout\" in mod && mod.ServerLayout) {\n      Layout = mod.ServerLayout;\n    }\n    if (\"ErrorBoundary\" in mod && mod.ErrorBoundary) {\n      if (\"ServerErrorBoundary\" in mod && mod.ServerErrorBoundary) {\n        throw new Error(\n          \"Module cannot have both an ErrorBoundary export and a ServerErrorBoundary export\",\n        );\n      }\n      ErrorBoundary = mod.ErrorBoundary;\n    } else if (\"ServerErrorBoundary\" in mod && mod.ServerErrorBoundary) {\n      ErrorBoundary = mod.ServerErrorBoundary;\n    }\n    if (\"HydrateFallback\" in mod && mod.HydrateFallback) {\n      if (\"ServerHydrateFallback\" in mod && mod.ServerHydrateFallback) {\n        throw new Error(\n          \"Module cannot have both a HydrateFallback export and a ServerHydrateFallback export\",\n        );\n      }\n      HydrateFallback = mod.HydrateFallback;\n    } else if (\"ServerHydrateFallback\" in mod && mod.ServerHydrateFallback) {\n      HydrateFallback = mod.ServerHydrateFallback;\n    }\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/remix-run/react-router/blob/6beaca39526d5716c3c112ebb0782765baa5a9ce/packages/react-router-dev/vite/rsc/virtual-route-config.ts#L22-L58","documentation":"In RSC mode a route's error UI can come from the client 'ErrorBoundary' export or the server 'ServerErrorBoundary' export, but not both. The framework-route wrapper throws when both are truthy to prevent an ambiguous error-rendering path — this fires whenever the route module is lazily loaded and both exports exist.","triggerScenarios":"A route module exporting both 'export function ErrorBoundary()' and 'export function ServerErrorBoundary()' with both truthy.","commonSituations":"Adding a server error boundary to a route that already had a client one; copying an RSC example's ServerErrorBoundary into an existing route without removing the old export.","solutions":["Remove 'ErrorBoundary' if errors for this route should render on the server","Remove 'ServerErrorBoundary' if the error UI must be interactive on the client","Keep shared error markup in a separate module imported by the surviving export"],"exampleFix":"// before\nexport function ErrorBoundary() { return <p>Something broke</p>; }\nexport function ServerErrorBoundary() { return <p>Server error</p>; }\n\n// after\nexport function ServerErrorBoundary() { return <p>Server error</p>; }","handlingStrategy":"validation","validationCode":"const PAIRS = [[\"ErrorBoundary\", \"ServerErrorBoundary\"]] as const;\nfor (const file of routeFiles) {\n  const mod: Record<string, unknown> = await import(pathToFileURL(file).href);\n  for (const [client, server] of PAIRS) {\n    if (mod[client] && mod[server]) {\n      throw new Error(`${file}: export either ${client} or ${server}, not both`);\n    }\n  }\n}","typeGuard":"function hasErrorBoundaryConflict(mod: Record<string, unknown>): boolean {\n  return Boolean(mod.ErrorBoundary) && Boolean(mod.ServerErrorBoundary);\n}","tryCatchPattern":null,"preventionTips":["Add the server variant only after removing the client one","Codemod or grep for dual error-boundary exports during RSC migration","Rely on CI builds to catch the static variant of this check"],"tags":["rsc","route-module","exports","error-boundary","naming"],"backgroundTag":"mutually-exclusive-exports","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"}