{"success":true,"name":"check-what-opts-a-next-js-route-into-dynamic-before-using-it","description":"About to use cookies, headers, or searchParams in a Next.js page","category":"ai-brimind","path":"ai-brimind/check-what-opts-a-next-js-route-into-dynamic-before-using-it/SKILL.md","file":"SKILL.md","content":"---\nname: check-what-opts-a-next-js-route-into-dynamic-before-using-it\ndescription: \"About to use cookies, headers, or searchParams in a Next.js page\"\n---\n\n# Check What Opts a Next.js Route Into Dynamic Before Using It\n\n## When to use\nProject is Next.js (App Router), and you are about to call cookies(), headers(), use searchParams, or set no-store inside a route.\n\n## Example request\nReading cookies() in a layout for one small banner → the entire route tree just became dynamic on every request. Using searchParams in a page for an optional filter → the whole page loses static rendering; a client component reading useSearchParams keeps the shell static. Adding cache: 'no-store' to one fetch in a shared component → every route importing it silently goes dynamic. Build output flips from ○ (static) to ƒ (dynamic) after your change → that symbol is Next.js telling you what you opted into.\n\n## Instructions\nIf condition: you are about to use cookies(), headers(), searchParams, no-store, or force-dynamic in a Next.js route → THEN: act as a developer who knows these are dynamic switches, not innocent reads. Before writing the line, state explicitly: this API opts the route (or the whole layout tree, if used in a layout) into dynamic rendering — is that what I actually want here? Classify the need: if the dynamic value is only needed in one small spot, isolate it — read it in a client component (useSearchParams), a server action, a route handler, or wrap the dynamic part in Suspense so the static shell survives. If the value is genuinely needed to render the whole page per-request, then dynamic is correct — say so and accept it knowingly. Distinguish the accidental opt-in (I just needed one cookie and didn't realize the cost) from the deliberate choice (this page is per-user by nature). After the change, verify with the build output: check whether the route still shows as static (○) or turned dynamic (ƒ), and confirm that matches your intention. If you are unsure whether a helper or imported component already contains one of these dynamic calls, inspect it before adding your own. Only keep the code once the route's rendering mode is confirmed to be the one you meant, and explain why the dynamic API sits at the smallest possible scope instead of infecting the whole tree.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #480\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}