1import { createFileRoute } from "@tanstack/react-router";
2import { createServerFn } from "@tanstack/react-start";
3import { Card } from "../components/Card.tsx";
4import { Counter } from "../components/Counter.tsx";
5
6// Runs on the server for both the SSR render and client navigations — in
7// the deployed Prisma Compute runtime (or, under `alchemy dev`, in TanStack Start's
8// own Vite dev server). The `env` values declared in alchemy.run.ts are
9// available on `process.env` either way.
10const getGreeting = createServerFn({ method: "GET" }).handler(
11 () => process.env.GREETING ?? "Hello!",
12);
13
14export const Route = createFileRoute("/")({
15 loader: () => getGreeting(),
16 component: Home,
17});
18
19function Home() {
20 const greeting = Route.useLoaderData();
21 return (
22 <main>
23 <h1 className="text-3xl font-bold">{greeting}</h1>
24 <Card
25 title="Styled with Tailwind CSS"
26 body="This card is a React component styled with Tailwind utilities."
27 />
28 <Counter />
29 </main>
30 );
31}