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

static.tsx

25 lines575 Bytes

1import { createFileRoute } from '@tanstack/react-router'
2import { createServerFn } from '@tanstack/react-start'
3import { env } from 'cloudflare:workers'
4​
5export const Route = createFileRoute('/static')({
6 loader: () => getData(),
7 component: StaticPage,
8})
9​
10const getData = createServerFn().handler(() => {
11 return {
12 myVar: env.MY_VAR,
13 }
14})
15​
16function StaticPage() {
17 const data = Route.useLoaderData()
18​
19 return (
20 <div>
21 <h1 data-testid="static-heading">Static Page</h1>
22 <p data-testid="static-content">The value is {data.myVar}</p>
23 </div>
24 )