#9189·ui

[bug]: SidebarProvider persistence causes Blocking Route in Next.js 16

Author: aress31Created Dec 23, 2025Updated Sep 25, 2026
Labelsarea: request

Feature description

The current persistence logic used by SidebarProvider does not integrate well with Next.js 16. Specifically, it triggers the following error:

Blocking Route
Server

Data that blocks navigation was accessed outside of <Suspense>.
This delays the entire page from rendering, resulting in a slow user experience. Next.js uses this error to ensure your app loads instantly on every navigation. Uncached data such as fetch(...), cached data with a low expiry time, or connection() are all examples of data that only resolve on navigation.

To fix this, you can either:
- Provide a fallback UI using <Suspense> around this component. This allows Next.js to stream its contents as soon as it is ready, without blocking the rest of the app.
- Move the asynchronous await into a Cache Component ("use cache"). This allows Next.js to statically prerender the component as part of the HTML document, making it instantly visible to the user.

Learn more: https://nextjs.org/docs/messages/blocking-route

--- SNIP ---

In this case, the data access is limited to reading a cookie to restore the sidebar open/closed state. I would strongly prefer not to introduce a <Suspense> boundary or a loading.tsx solely for this purpose, nor to convert the layout into a client component just to persist UI state.

If there is a more modern or idiomatic approach for persisting sidebar state in this scenario, I would be very interested to hear it.

typescript
import type { CSSProperties, ReactNode } from "react";

import { cookies } from "next/headers";

import { AppHeader, AppSidebar } from "@/components/my-components";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";

interface DashboardLayoutProps {
  children: ReactNode;
}

export default async function DashboardLayout({
  children,
}: DashboardLayoutProps) {
  const defaultOpen = (await cookies()).get("sidebar_state")?.value === "true";

  return (
    <SidebarProvider
      defaultOpen={defaultOpen}
      style={
        {
          "--header-height": "48px",
          "--sidebar-width": "256px",
          "--sidebar-width-icon": "40px",
        } as CSSProperties
      }
    >
      <AppSidebar />
      <SidebarInset>
        <AppHeader />
        <div className="@container/main flex flex-1 flex-col p-4 md:p-6">
          {children}
        </div>
      </SidebarInset>
    </SidebarProvider>
  );
}

Affected component/components

No response

Additional Context

Additional details here...

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues and PRs