Pages router: API for shallow routing
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Read the implementation of router.visit first and trace what it does in order: the fetch, the route-state update, the history write and the scroll-restoration bookkeeping. Compare that with the raw history.replaceState fallback described here, which leaves useRouter().url and .query stale, and identify where route state is derived so a shallow variant can update it without fetching. Done means router.visit(url, { replace: true, shallow: true }) changes history and router state while no request runs and deferred props are untouched, with a test covering the no-fetch guarantee.
Written by the indexing model from the issue text.
Description
Void version: 1.9.1, affecting every adapter
Use case
The simplest that I hit: A page has multiple side panels with info. Which panel is open depends on the query string (/page?panel=X), so the view can be shared and other pages can link to it.
The server ignores the param: it's left out of revalidateQueryAllowlist, so every variant shares one ISR entry, and the panel opens on the client.
When the user opens, switches or closes a panel, ?panel= should change in place: no new history entry, no request, no re-render.
Current status with today's API
The only Void way to change the query is
router.visit(url, { replace: true, preserveState: true, preserveScroll: true });
which is a full GET navigation. For state the server doesn't render, that means:
- The page data is fetched again on every change, in our case that's about 122 KB except the exact entry was cached already.
- Deferred props go back to loading, which would include our panel.
So instead of using it we fall back to the raw history.replaceState. That works, but the router no longer matches the address bar: useRouter().url / .query keep reporting the old query until the next navigation.
API Proposal
Something like
router.replaceUrl(url); // or router.visit(url, { replace: true, shallow: true })
This would:
- write history (replace, or push as an option),
- update the router's route state
- keep scroll-restoration bookkeeping in step,
- does not fetch, re-render, or touch deferred props.
This is similar to what other meta frameworks do, e.g. SvelteKit's replaceState or Next.js's shallow routing.
- Dominant language
- TypeScript
- Stars
- 684
- Forks
- 83
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 219
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from voidzero-dev/void
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
voidzero-dev/void#835 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
voidzero-dev/void#834 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
voidzero-dev/void#832 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
voidzero-dev/void#825 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
voidzero-dev/void#808 · 1 comment ·
Maintainers usually reply within 1 day
All issues in voidzero-dev/void
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
open-webui/tether#52 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AykutSarac/jsoncrack.com#616 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
melgarafael/DeskcommCRM#4679 ·
Maintainers usually reply within 1 day
-
enhancement size:medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day