Skip to content

TanStack Start

GCP.Website.TanStackStart deploys a TanStack Start app, React or Solid, to Cloud Run. Alchemy runs your own vite build and serves the result from a Node server.

The build integration ships separately. It only runs at deploy time, so a dev dependency is enough:

Terminal window
pnpm add -D @alchemy.run/frontend-frameworks@latest

Docker has to be running when you deploy. The image is built on your machine.

alchemy.run.ts
import * as Alchemy from "alchemy";
import * as GCP from "@alchemy.run/gcp";
import * as Effect from "effect/Effect";
export const Website = GCP.Website.TanStackStart("Website");
export default Alchemy.Stack(
"MySite",
{ providers: GCP.providers(), state: GCP.state() },
Effect.gen(function* () {
const site = yield* Website;
return { url: site.url };
}),
);

Run alchemy deploy. site.url is the Cloud Run service URL.

alchemy.run.ts
export const Website = GCP.Website.TanStackStart("Website");
export const Website = GCP.Website.TanStackStart("Website", {
env: {
GREETING: "Hello from Cloud Run!",
},
});

Server functions read it from process.env:

src/routes/index.tsx
const getGreeting = createServerFn({ method: "GET" }).handler(
() => process.env.GREETING ?? "Hello!",
);

Your vite.config.ts needs no adapter. Keep the TanStack Start plugin as it is.

export const Website = GCP.Website.TanStackStart("Website", {
scaling: { minInstanceCount: 1 },
resources: { limits: { cpu: "1", memory: "1Gi" } },
});

One warm instance means no cold start for the first visitor. See Websites for the other settings.

alchemy dev runs the framework’s dev server with hot reload and creates nothing in the cloud. Wrap the site in Alchemy.remote() to deploy it for real during dev.