You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c42173e
Browse filesBrowse the repository at this point in the historyBrowse files
feat(pages): mark Links to the page that is loading (#698)
`Link` now adds `data-void-pending` while a visit to its destination
loads, so a slow navigation shows feedback on the link itself.
- A link is pending when the visit's path, query, hash and method all
match its own. Unlike `data-void-active`, the query counts.
- Every link to the destination is marked, not just the clicked one.
- Non-GET Links, which render a `<button>`, are pending while their own
request runs.
**Worth knowing**
- `router.refresh()` marks links to the current page while it runs.
- A prefetched page can show the attribute for a moment. The guide's CSS
example adds a transition delay to hide this.
- React `Link`s now re-render when a visit starts and ends.
**Tests:** the browser contract passes for all four adapters in dev and
preview, along with `vp run check` and the full `vp run test`. The one
failure in the full run, a WebSocket playground timeout under load,
passes when run alone.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/guide/pages-routing/overview.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -324,6 +324,22 @@ A link is active only on its own path by default. Set `activeMatch="prefix"` to
324
324
325
325
Paths match the way pages are routed: letter case and trailing slashes count, while the query string and hash are ignored. Links to other origins and non-GET links are never active. An `aria-current` or `data-void-active` you pass to `Link` replaces the computed value.
326
326
327
+
### Pending links
328
+
329
+
While a page loads, `Link` adds `data-void-pending` to every link to it. Use it to show that a click is being handled:
330
+
331
+
```css
332
+
a[data-void-pending] {
333
+
opacity: 0.6;
334
+
/* Skip visits that finish quickly, such as to a prefetched page */
335
+
transition: opacity 0.15s0.1s;
336
+
}
337
+
```
338
+
339
+
A link is pending only while its exact destination loads. The path, query and hash must all match, so a link to `/users?page=2` isn't pending while `/users?page=3` loads. A non-GET link, which renders a `<button>`, is pending while a request with its method to its `href` runs. `router.refresh()` reloads the current page, so links to it are pending during a refresh.
340
+
341
+
A `data-void-pending` you pass to `Link` replaces the computed value. For a loading indicator that covers the whole page, use [`useNavigation()`](../../reference/api/pages.md).
342
+
327
343
### Prefetching
328
344
329
345
Add `prefetch` to a `Link` to load its page before the user clicks, so the visit doesn't wait for the server:
0 commit comments