Open History to see the last commit
1import { useQueryClient } from '@tanstack/solid-query'
2import { isServer } from 'solid-js/web'
3import { Title } from '@solidjs/meta'
4import { UserInfo, userInfoQueryOpts } from '~/components/user-info'
5β
6export const route = {
7 load: () => {
8 const queryClient = useQueryClient()
9 // Prefetching the user info and caching it for 15 seconds.
10 queryClient.prefetchQuery(userInfoQueryOpts({ sleep: 500, gcTime: 15000 }))
11 },
12}
13β
14export default function Prefetch() {
15 return (
16 <main>
17 <Title>Solid Query - Prefetch</Title>
18β
19 <h1>Solid Query - Prefetch Example</h1>
20β
21 <div class="description">
22 <p>
23 SolidStart now supports link prefetching. This means that when a user
24 hovers over a link, the browser can prefetch the data for that page
25 before the user even clicks on the link. This can make navigating
26 around your app feel much faster.
27 </p>
28 <p>
29 To see this in action, go to the home page and reload the page. Then
30 hover over the "Prefetch" link in the navigation. You should see the
31 user data prefetch in the background and in the devtools. When you
32 click on the link, the page should load instantly.
33 </p>
34 </div>
35β
36 <UserInfo sleep={500} />
37 </main>
38 )
39}