Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

client-only.tsx

25 lines651 Bytes

1import { ClientOnly, createFileRoute } from '@tanstack/react-router'
2import { WindowSize } from '~/components/WindowSize'
3​
4export const Route = createFileRoute('/client-only')({
5 component: ClientOnlyPage,
6})
7​
8function ClientOnlyPage() {
9 return (
10 <div className="p-2">
11 <h3 data-testid="client-only-heading">Client Only Demo</h3>
12 <p>
13 The component below uses <code>window</code> APIs that only exist in the
14 browser.
15 </p>
16 <ClientOnly
17 fallback={
18 <div data-testid="loading-fallback">Loading window size...</div>
19 }
20 >
21 <WindowSize />
22 </ClientOnly>
23 </div>
24 )