Next.js Discord

Discord Forum

(live demo to reproduce) Query Params caching on static page when navigating home - how to fix??

Unanswered
Oak apple gall wasp posted this in #help-forum
Open in Discord
Oak apple gall waspOP
I’m seeing a production-only App Router navigation issue with a fully static homepage that uses query params only for client-side filtering via nuqs.

Repro on https://tarkov.directory

1. Visit /
2. Set a client-side filter, producing a URL like /?search=m4
3. Hard refresh on /?search=m4
4. Click into a detail route, e.g. /guns/...
5. Click the site logo/home link, which is a normal Next <Link href="/" />

Expected: navigate to /

Actual in production: navigates back to /?search=m4

This does not reproduce in next dev, but does reproduce with next build && next start and in production.

The homepage is intended to stay fully static. It does not read searchParams on the server; the query params are only client-side UI state for filtering. If I make the page read searchParams, the issue goes away, but that changes the route from fully static to partially/dynamic, which I don’t want.

My current understanding is that after a hard load on /?search=m4, Next’s client router/cache may retain the homepage canonical URL including the query string. Later, even though the visible URL is a detail route with no query params, navigating with <Link href="/" /> restores the cached /?search=m4 instead of the literal /.

Question: what is the proper Next.js/App Router way to clear or avoid this stale query state while keeping the homepage fully static?

3 Replies

Oak apple gall waspOP
I might be missing something, but this feels like a bug to me, it should be extremely trivial to do this, no?
Oak apple gall waspOP
Bump