Using searchParams in Next.js Pages Forces Dynamic Rendering Silently
In Next.js, simply accepting the searchParams prop in a page component causes the entire route to be treated as dynamically rendered, even if the prop is never meaningfully used. Unlike cookies() or headers(), searchParams looks like a normal React prop destructure, giving no visual signal that it carries request-specific implications. The behavior is intentional — since query strings vary per request, Next.js cannot pre-generate a single static HTML output for such pages. The real problem arises when searchParams is included out of habit or copied from another component, unnecessarily stripping static caching benefits from pages like an About or Contact page. Developers can identify affected routes by running a production build and checking whether routes expected to be static are instead flagged as dynamic.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in