Prefetch Link

A link component that prefetches page content for faster navigation.

Installation

Import the component from the passport-ui package.

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

Usage

Basic example showing how to use the component.

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

Additional resources

Documentation and examples are available in Storybook.