Prefetch Link

A link component that prefetches page content for faster navigation.

Installation

Import the component from the passport-ui package.

components/example.tsx
1
2
import { PrefetchLink } from "passport-ui";
import { Button } from "passport-ui";

Usage

Basic example showing how to use the component.

components/example.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<PrefetchLink href="/about">About Page</PrefetchLink>
{/* With hover prefetching */}
<PrefetchLink
href="/products"
prefetchOnHover={true}
prefetchDelay={100}
>
Products
</PrefetchLink>
{/* With visibility prefetching */}
<PrefetchLink
href="/contact"
prefetchOnVisible={true}
>
Contact Us
</PrefetchLink>
{/* As button */}
<Button asChild>
<PrefetchLink href="/dashboard">
Go to Dashboard
</PrefetchLink>
</Button>
{/* External link with prefetching disabled */}
<PrefetchLink
href="https://external.com"
prefetchOnHover={false}
target="_blank"
>
External Link
</PrefetchLink>

Additional resources

Documentation and examples are available in Storybook.