TraceResolve
MCP
Back to CatalogNext.js 15

Next.js 15: Dynamic server usage: revalidatePath cannot be called during static generation

Error: Dynamic server usage: Route /posts couldn't be rendered statically because it used `revalidatePath`.
Immediate Remediation
bash
grep -R "revalidatePath" app --include='*.tsx' --include='*.ts' | grep -v "^app/api/" || echo "Move revalidatePath into a Server Action or Route Handler (POST/DELETE), never in the synchronous root render."
Root Cause Analysis

Calling `revalidatePath` during the synchronous render of a statically generated route forces the route to become dynamic, which is not allowed during static generation; it must be invoked in a mutating context like a Server Action or Route Handler.

Verification & Guardrails

  • Only call `revalidatePath` in Server Actions, Route Handlers, or after a mutation—never in the component body during render.
  • If the route must be dynamic, add `export const dynamic = 'force-dynamic'` to the page, but prefer moving the revalidation call to a POST/DELETE handler.
  • Test with `next build` to confirm the route is no longer marked as static and with `next start` to verify revalidation works at runtime.

Have a custom or uncategorized crash?

Run your trace through our in-memory client privacy sandbox for instant SRE remediation.

Open Diagnostic Studio