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