Next.js/tRPC RootLayout Caching Error
I'm hitting a specific rendering/caching issue in my Next.js (App Router)
RootLayout when trying to fetch data via tRPC.
💻 Code Snippet (app/layout.tsx)
I am trying to fetch the list of categories server-side within the layout:
🚨 The Error
I am getting the following critical error, which points to something in the tRPC context creation:
Error: Route "/": Uncached data was accessed outside of <Suspense>. This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-routeThe traceback points to the
headers() call within my createContext function in src/trpc/server.ts:
Any advice on how to properly integrate tRPC server-side data fetching in the Next.js App Router root layout would be massively.0 Replies