AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Searchparams Not Working When `CacheComponents` And `DraftMode` Are Enabled

SearchParams aren't updated on client-side navigation when experimental cacheComponents and Draft Mode are both enabled; the page always shows the initial category until a hard reload. This is a caching key omission in Next.js App Router.

highConfidence 78%Next.jsAffected V16.4.0-Canary.33

Origin Analysis

With `cacheComponents` enabled, the component cache key does not include `searchParams` when Draft Mode is active. During client-side transitions, the router reuses the first cached RSC payload for the route, so `await searchParams` keeps returning the stale initial values. Underlying design flaw: the new component cache layer is not fully integrated with draft-mode dynamic rendering.
1. Enable `experimental.cacheComponents` in next.config and deploy/start the app with Draft Mode support. 2. Visit /api/draft to enable Draft Mode and redirect to /. 3. Click 'Overview' and then each category link (e.g. ?category=A). 4. Observe the paragraph always shows the same category. 5. Hard-reload the URL and see the correct category render.

Fixing Code Block

Edge Case Audit

Disables caching for this route, increasing server load; only apply to affected routes. Rollback by removing the export after upgrading to a fixed Next.js version. Not a fix for the underlying cacheComponents bug, so other routes using draft mode and searchParams may still be affected.

Ecosystem Topology