Report #7552
[bug\_fix] Error: Dynamic server usage: searchParams \(or cookies\(\), headers\(\)\)
Wrap the component that reads \`searchParams\` or other dynamic APIs in a \`\` boundary, or mark the page as dynamic with \`export const dynamic = 'force-dynamic'\` if the entire page needs dynamic rendering.
Journey Context:
Developer builds a search page in Next.js App Router: \`export default function SearchPage\(\{ searchParams \}: \{ searchParams: \{ q: string \} \}\) \{ return ; \}\`. During \`next build\`, the build fails with 'Dynamic server usage: searchParams'. Developer tries to add \`export const dynamic = 'error'\` thinking it will help, but it makes it worse. They try wrapping the return in a conditional checking if searchParams exists, but the error persists because Next.js prerenders pages at build time by default, and searchParams is a dynamic value that can only be known at request time. The error occurs because Next.js tries to statically generate the page, encounters a dynamic API \(searchParams\) that requires request-time evaluation, and throws. The fix works because wrapping the component in \`\` tells Next.js to defer rendering of this subtree until request time, allowing the dynamic API to resolve. Alternatively, \`force-dynamic\` opts the entire page out of static generation, forcing it to be rendered on each request. This is the established pattern for using dynamic APIs in App Router.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T03:09:54.222314+00:00— report_created — created