{"record":{"id":"adb420ef6224f6bd","repo":"facebook/docusaurus","slug":"can-t-find-any-sidebar-with-id-sidebarid-in-v","errorCode":null,"errorMessage":"Can't find any sidebar with id \"${sidebarId}\" in version${versions.length > 1 ? 's' : ''} ${versions.map((version) => version.name).join(', ')}\".\nAvailable sidebar ids are:\n- ${allSidebars.map((entry) => entry[0]).join('\\n- ')}","messagePattern":"Can't find any sidebar with id \"(.+?)\" in version(.+?) (.+?)\"\\.\nAvailable sidebar ids are:\n- (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx","lineNumber":333,"sourceCode":" * be ambiguous. This hook would always return a sidebar to be linked to. See\n * also {@link useDocsVersionCandidates} for how this selection is done.\n *\n * @throws This hook throws if a sidebar with said ID is not found.\n */\nexport function useLayoutDocsSidebar(\n  sidebarId: string,\n  docsPluginId?: string,\n): GlobalSidebar {\n  const versions = useDocsVersionCandidates(docsPluginId);\n  return useMemo(() => {\n    const allSidebars = versions.flatMap((version) =>\n      version.sidebars ? Object.entries(version.sidebars) : [],\n    );\n    const sidebarEntry = allSidebars.find(\n      (sidebar) => sidebar[0] === sidebarId,\n    );\n    if (!sidebarEntry) {\n      throw new Error(\n        `Can't find any sidebar with id \"${sidebarId}\" in version${\n          versions.length > 1 ? 's' : ''\n        } ${versions.map((version) => version.name).join(', ')}\".\nAvailable sidebar ids are:\n- ${allSidebars.map((entry) => entry[0]).join('\\n- ')}`,\n      );\n    }\n    return sidebarEntry[1];\n  }, [sidebarId, versions]);\n}\n\n/**\n * The layout components, like navbar items, must be able to work on all pages,\n * even on non-doc ones where there's no version context, so a doc ID could be\n * ambiguous. This hook would always return a doc to be linked to. See also\n * {@link useDocsVersionCandidates} for how this selection is done.\n *\n * @throws This hook throws if a doc with said ID is not found.","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx#L315-L351","documentation":"Thrown by useLayoutDocsSidebar() when no sidebar with the given sidebarId exists in ANY of the candidate versions. It collects all sidebars across versions (useDocsVersionCandidates: active + preferred + latest), and if none matches sidebarId, throws a message listing every available sidebar id so you can pick a valid one. This hook is designed for layout components (navbar items) that must resolve a sidebar even on non-doc pages, hence the multi-version search. The useMemo recomputes when sidebarId or the candidate versions change.","triggerScenarios":"A navbar item / layout config references a sidebar id (e.g. `{type: 'doc', sidebarId: 'tutorial'})` that was never declared in sidebars.js, was renamed, or only existed in a removed version. The throw happens at render time inside useMemo.","commonSituations":"Renaming a sidebar id in sidebars.js but leaving stale references in docusaurus.config.ts navbar items; pointing at a sidebar id that lives in a different docs plugin id (docsPluginId mismatch); deleting a versioned sidebar while config still references it.","solutions":["Read the 'Available sidebar ids' list in the error and use one of those exact ids.","Open sidebars.js (or the versioned sidebars) and confirm the sidebar id spelling matches the config reference exactly.","If the sidebar lives in a different docs plugin, pass the correct docsPluginId as the second argument to useLayoutDocsSidebar.","If the id was renamed, update all navbar/layout references to the new id."],"exampleFix":"// before\n// docusaurus.config.ts\nnavbar: [{ type: 'doc', sidebarId: 'tutorials', ... }]\n// sidebars.js\nexport default { learn: [{type: 'autogenerated', dirName: '.'}] };\n// after: align the id\nnavbar: [{ type: 'doc', sidebarId: 'learn', ... }]","handlingStrategy":"validation","validationCode":"import {useDocsVersionCandidates} from '@docusaurus/plugin-content-docs/client';\n\nfunction useKnownSidebarId(sidebarId: string, docsPluginId?: string) {\n  const versions = useDocsVersionCandidates(docsPluginId);\n  const allIds = versions.flatMap((v) =>\n    v.sidebars ? Object.keys(v.sidebars) : [],\n  );\n  if (!allIds.includes(sidebarId)) {\n    return {valid: false, available: allIds} as const;\n  }\n  return {valid: true, available: allIds} as const;\n}\n// const check = useKnownSidebarId('tutorial'); if (!check.valid) return null;","typeGuard":"const isKnownSidebarId = (\n  id: string,\n  versions: {sidebars?: Record<string, unknown>}[],\n): boolean => versions.some((v) => v.sidebars && id in v.sidebars);","tryCatchPattern":null,"preventionTips":["Validate sidebar id against sidebars.js before referencing it in navbar/layout config.","Keep sidebar ids stable; when renaming, grep config for all references.","Pass the correct docsPluginId when multiple docs plugins exist."],"tags":["docs","sidebar","navbar","versioning","config"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}