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
Add support for `<Link prefetch="viewport">` to prefetch links when they enter the viewport via an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver)
Copy file name to clipboardexpand all lines: docs/components/link.md
+2
Original file line number
Diff line number
Diff line change
@@ -30,12 +30,14 @@ In the effort to remove all loading states from your UI, `Link` can automaticall
30
30
<Linkprefetch="none" />
31
31
<Linkprefetch="intent" />
32
32
<Linkprefetch="render" />
33
+
<Linkprefetch="viewport" />
33
34
</>
34
35
```
35
36
36
37
-**"none"** - Default behavior. This will prevent any prefetching from happening. This is recommended when linking to pages that require a user session that the browser won't be able to prefetch anyway.
37
38
-**"intent"** - Recommended if you want to prefetch. Fetches when Remix thinks the user intends to visit the link. Right now the behavior is simple: if they hover or focus the link it will prefetch the resources. In the future we hope to make this even smarter. Links with large click areas/padding get a bit of a head start. It is worth noting that when using `prefetch="intent"`, `<link rel="prefetch">` elements will be inserted on hover/focus and removed if the `<Link>` loses hover/focus. Without proper `cache-control` headers on your loaders, this could result in repeated prefetch loads if a user continually hovers on and off a link.
38
39
-**"render"** - Fetches when the link is rendered.
40
+
-**"viewport"** - Fetches while the link is in the viewport
39
41
40
42
<docs-error>You may need to use the <code>:last-of-type</code> selector instead of <code>:last-child</code> when styling child elements inside of your links</docs-error>
Copy file name to clipboardexpand all lines: docs/components/nav-link.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ toc: false
5
5
6
6
# `<NavLink>`
7
7
8
-
A `<NavLink>` is a special kind of `<Link>` that knows whether or not it is "active" or "pending". This is useful when building a navigation menu, such as a breadcrumb or a set of tabs where you'd like to show which of them is currently selected. It also provides useful context for assistive technology like screen readers.
8
+
A `<NavLink>` is a special kind of [`<Link>`][link] that knows whether or not it is "active" or "pending". This is useful when building a navigation menu, such as a breadcrumb or a set of tabs where you'd like to show which of them is currently selected. It also provides useful context for assistive technology like screen readers.
9
9
10
10
```tsx
11
11
import { NavLink } from"@remix-run/react";
@@ -122,3 +122,4 @@ Adding the `caseSensitive` prop changes the matching logic to make it case sensi
122
122
When a `NavLink` is active it will automatically apply `<a aria-current="page">` to the underlying anchor tag. See [aria-current][aria-current] on MDN.
Copy file name to clipboardexpand all lines: docs/other-api/dev-v2.md
+17
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,22 @@ The dev server will:
37
37
3. Restart your app server whenever rebuilds succeed
38
38
4. Send code updates to the browser via Live Reload and HMR + Hot Data Revalidation
39
39
40
+
<docs-info>
41
+
42
+
What is "Hot Data Revalidation"?
43
+
44
+
Like HMR, HDR is a way of hot updating your app without needing to refresh the page.
45
+
That way you can keep your app state as your edits are applied in your app.
46
+
HMR handles client-side code updates like when you change the components, markup, or styles in your app.
47
+
Likewise, HDR handles server-side code updates.
48
+
49
+
That means any time your change a `loader` on your current page (or any code that your `loader` depends on), Remix will re-fetch data from your changed loader.
50
+
That way your app is _always_ up-to-date with the latest code changes, client-side or server-side.
51
+
52
+
To learn more about how HMR and HDR work together, check out [Pedro's talk at Remix Conf 2023][legendary-dx].
53
+
54
+
</docs-info>
55
+
40
56
### With `remix-serve`
41
57
42
58
Enable the v2 dev server:
@@ -342,6 +358,7 @@ That way the dev server can detect loader changes on rebuilds.
342
358
343
359
While the initial build slowdown is inherently a cost for HDR, we plan to optimize rebuilds so that there is no perceivable slowdown for HDR rebuilds.
0 commit comments