facebook/docusaurus · error · Error

DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't

Error message

DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.

What it means

Thrown by `DocSidebarNavbarItem` when the referenced sidebar has no `link` property (no first/default doc to point at). The navbar item tries to link to the sidebar's landing doc; if the sidebar definition exposes no `link`, there is nowhere for the navbar entry to navigate, so the render aborts.

Source

Thrown at packages/docusaurus-theme-classic/src/theme/NavbarItem/DocSidebarNavbarItem.tsx:25

import React, {type ReactNode} from 'react';
import {
  useActiveDocContext,
  useLayoutDocsSidebar,
} from '@docusaurus/plugin-content-docs/client';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';

export default function DocSidebarNavbarItem({
  sidebarId,
  label,
  docsPluginId,
  ...props
}: Props): ReactNode {
  const {activeDoc} = useActiveDocContext(docsPluginId);
  const sidebarLink = useLayoutDocsSidebar(sidebarId, docsPluginId).link;
  if (!sidebarLink) {
    throw new Error(
      `DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.`,
    );
  }
  return (
    <DefaultNavbarItem
      exact
      {...props}
      isActive={() => activeDoc?.sidebar === sidebarId}
      label={label ?? sidebarLink.label}
      to={sidebarLink.path}
    />
  );
}

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Verify the `sidebarId` matches a key in your sidebars config and that the sidebar has at least one doc that resolves to a `link`.
  2. Set a sidebar index (e.g. via `docId` on an autogenerated category, or a top-level doc) so the sidebar has a landing route.
  3. Confirm `docsPluginId` (for multi-instance docs) points at the plugin instance that owns the sidebar.
  4. If the sidebar intentionally has no link, switch the navbar item to `type: 'doc'` pointing at a specific doc instead.

Example fix

// before
navbar: [
  {type: 'docSidebar', sidebarId: 'emptySidebar'}
]
// after — give the sidebar a landing doc, then reference it
sidebars: {mySidebar: [{type: 'autogenerated', dirName: '.'}]}
// (ensure _category_.json or docs intro resolves to a `link`)
navbar: [
  {type: 'docSidebar', sidebarId: 'mySidebar'}
]
Defensive patterns

Strategy: validation

Validate before calling

import {useLayoutDocsSidebar} from '@docusaurus/ThemeCommon';
const sidebar = useLayoutDocsSidebar(sidebarId, docsPluginId);
if (!sidebar?.link) {
  // render a fallback navbar item or skip, do not mount DocSidebarNavbarItem
  return null;
}

Type guard

function sidebarHasLink(s: {link?: unknown} | null): s is {link: {path: string; label: string}} {
  return !!s?.link && typeof s.link.path === 'string';
}

Prevention

When it happens

Trigger: Configuring a navbar item `type: 'docSidebar', sidebarId: 'someSidebar'` where `someSidebar` has no `link` resolved (e.g. it is an empty sidebar, only contains autogenerated content with no index, or the sidebar ID is for a versioned docs instance without a default doc).

Common situations: Mis-typed `sidebarId` in `docusaurus.config.js`; a sidebar that was emptied or renamed; using a sidebar from a docs plugin instance that has no default route; referencing a sidebar ID that exists only in a different `docsPluginId` than the one declared.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/5b3e93bcf7331b70. Report an issue: GitHub.