@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
mdx 97 lines 2.45 KB
Raw
1 ---
2 title: TanStack Start
3 description: Deploy a TanStack Start app (React or Solid) to Cloud Run with GCP.Website.TanStackStart — your own vite build, served by a Node server.
4 sidebar:
5 order: 15
6 ---
7
8 import PackageManagers from "../../../../components/PackageManagers.astro";
9
10 export const devDeps = "@alchemy.run/frontend-frameworks";
11
12 `GCP.Website.TanStackStart` deploys a
13 [TanStack Start](https://tanstack.com/start) app, React or Solid, to
14 Cloud Run. Alchemy runs your own `vite build` and serves the result
15 from a Node server.
16
17 ## Install
18
19 The build integration ships separately. It only runs at deploy time,
20 so a dev dependency is enough:
21
22 <PackageManagers dev={devDeps} />
23
24 Docker has to be running when you deploy. The image is built on your
25 machine.
26
27 ## Deploy the site
28
29 ```typescript
30 // alchemy.run.ts
31 import * as Alchemy from "alchemy";
32 import * as GCP from "@alchemy.run/gcp";
33 import * as Effect from "effect/Effect";
34
35 export const Website = GCP.Website.TanStackStart("Website");
36
37 export default Alchemy.Stack(
38 "MySite",
39 { providers: GCP.providers(), state: GCP.state() },
40 Effect.gen(function* () {
41 const site = yield* Website;
42 return { url: site.url };
43 }),
44 );
45 ```
46
47 Run `alchemy deploy`. `site.url` is the Cloud Run service URL.
48
49 ## Pass environment variables
50
51 ```diff lang="typescript"
52 // alchemy.run.ts
53 -export const Website = GCP.Website.TanStackStart("Website");
54 +export const Website = GCP.Website.TanStackStart("Website", {
55 + env: {
56 + GREETING: "Hello from Cloud Run!",
57 + },
58 +});
59 ```
60
61 Server functions read it from `process.env`:
62
63 ```typescript
64 // src/routes/index.tsx
65 const getGreeting = createServerFn({ method: "GET" }).handler(
66 () => process.env.GREETING ?? "Hello!",
67 );
68 ```
69
70 ## Configure Vite
71
72 Your `vite.config.ts` needs no adapter. Keep the TanStack Start plugin
73 as it is.
74
75 ## Tune Cloud Run
76
77 ```typescript
78 export const Website = GCP.Website.TanStackStart("Website", {
79 scaling: { minInstanceCount: 1 },
80 resources: { limits: { cpu: "1", memory: "1Gi" } },
81 });
82 ```
83
84 One warm instance means no cold start for the first visitor. See
85 [Websites](/gcp/frontend/websites#tune-cloud-run) for the other
86 settings.
87
88 ## Local development
89
90 `alchemy dev` runs the framework's dev server with hot reload and
91 creates nothing in the cloud. Wrap the site in `Alchemy.remote()` to
92 deploy it for real during dev.
93
94 ## Where next
95
96 - [Websites](/gcp/frontend/websites) — the settings every site shares.
97 - [Website reference](/providers/gcp/website#tanstackstart) — every prop.