Pages router: API for shallow routing
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- frontend
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- TypeScript
- 星號
- 684
- 分支
- 83
- 平均合併
- 15 小時 22 分鐘
- 30 天內合併 PR
- 219
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/void 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
voidzero-dev/void#835 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
voidzero-dev/void#834 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 32/100
voidzero-dev/void#832 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 45/100
voidzero-dev/void#825 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
voidzero-dev/void#808 · 1 則留言 ·
維護者通常 1 天內回覆
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
open-webui/tether#52 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
AykutSarac/jsoncrack.com#616 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
melgarafael/DeskcommCRM#4679 ·
維護者通常 1 天內回覆
-
enhancement size:medium
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆