Repository navigation
Always show fresh pages after in-app navigation (dashboard new-form fix) - #16
Merged
Merged
Conversation
Next.js sometimes shows a page from its in-memory copy without asking the server: on Back/Forward, and, despite staleTimes.dynamic = 0, for pages first opened inside the app (e.g. the dashboard after signing in). Reproduced on a live install: Dashboard click made no request and the new form was missing. NavProgress now notes every page data request (RSC, not prefetch) as it starts. After each in-app page change, if the server wasn't asked for that page, it calls router.refresh(): the copy shows at once, then the fresh page. Normal navigations still make exactly one request. Replaces the popstate-only refresh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
components/nav-progress.tsxrecords each page data request Next.js starts (RSC: 1, excluding prefetches). After every in-app page change it checks whether the server was asked for that page; if not (the page came from Next.js's in-memory copy), it callsrouter.refresh(). Replaces the popstate-only refresh from #14.Why
Reproduced on a live 1.1.3 install (behind Cloudflare, not cached there): signed in → New form → builder → Dashboard. The click made no request for
/, and the new form was missing until a reload.staleTimes.dynamic = 0(#13) didn't cover it because the dashboard copy came from opening it inside the app (after sign-in), which Next.js 14 reuses anyway. Callingrouter.refresh()there brought the form in.Testing
tsc --noEmitpasses; local production build (next build && next start)./(no double fetch)./.router.refresh()after the stale Dashboard click showed the missing form. The test form was then deleted for good (Trash → Delete forever).