Skip to content
Discussion options

You must be logged in to vote

Hi! This happens because Next.js attempts to statically pre-render (SSG) the route by default during next build, but reading dynamic request data like cookies() or headers() forces the component to require request-time evaluation.

You don't need to convert anything to Client Components ('use client'). You just need to explicitly tell Next.js to treat this route segment as dynamic by adding the route segment config option at the top of your page.tsx or layout.tsx:

TypeScript
// app/dashboard/page.tsx
import { cookies } from 'next/headers';

// 1. Force dynamic rendering for this route
export const dynamic = 'force-dynamic'; 

export default async function DashboardPage() {
  const cookieSt…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Jordid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants