Error: Dynamic server usage: Route /page couldn't be rendered statically
You’re using dynamic features (cookies, headers, searchParams) in a route that Next.js is trying to statically generate.
Fix 1: Mark the route as dynamic
// Add this to your page
export const dynamic = 'force-dynamic';
Fix 2: Use generateStaticParams for dynamic routes
export async function generateStaticParams() {
const posts = await getPosts();
return posts.map(post => ({ slug: post.slug }));
}
Fix 3: Wrap dynamic parts in Suspense
import { Suspense } from 'react';
export default function Page() {
return (
<Suspense fallback={<div>Loading...</div>}>
<DynamicContent />
</Suspense>
);
}