1import { frameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
2
3/** The framework-integration package that drives the TanStack Start build. */
4export const TANSTACK_START_FRAMEWORK_SPECIFIER =
5 "@alchemy.run/frontend-frameworks/tanstack-start";
6
7/** The Node container deploy target for the TanStack Start build. */
8export const TANSTACK_START_NODE_TARGET_SPECIFIER =
9 "@alchemy.run/frontend-frameworks/tanstack-start/node";
10
11export interface TanStackStartProps extends FrameworkSiteProps {}
12
13/**
14 * Deploy a [TanStack Start](https://tanstack.com/start) application to Cloud Run:
15 * the SSR server in a Cloud Run container, client assets baked into the image, served
16 * assets-first then the framework handler.
17 *
18 * The build runs through
19 * `@alchemy.run/frontend-frameworks/tanstack-start` with the
20 * `@alchemy.run/frontend-frameworks/tanstack-start/node` deploy target —
21 * both must be installed in your project, alongside
22 * `@tanstack/react-start` (or `@tanstack/solid-start`) and `vite`.
23 *
24 * Your `vite.config.ts` needs no adapter wiring: TanStack Start is pure
25 * Vite, so the integration drives the project's own `vite build`, forces
26 * the SSR bundle to be self-contained, and wraps its fetch handler as a
27 * Node HTTP server on Cloud Run's `PORT` (8080).
28 *
29 *
30 * ### Creating TanStack Start Sites
31 * **Example:** Basic TanStack Start App
32 * ```typescript
33 * const site = yield* GCP.Website.TanStackStart("Web", {
34 * rootDir: "./app",
35 * });
36 * ```
37 *
38 * **Example:** Warm Instance with More Memory
39 * ```typescript
40 * const site = yield* GCP.Website.TanStackStart("Web", {
41 * rootDir: "./app",
42 * scaling: { minInstanceCount: 1 },
43 * resources: { limits: { cpu: "1", memory: "1Gi" } },
44 * });
45 * ```
46 *
47 * ### Server Configuration
48 * **Example:** Process Environment
49 * ```typescript
50 * const site = yield* GCP.Website.TanStackStart("Web", {
51 * rootDir: "./app",
52 * env: {
53 * GREETING: "Hello from TanStack Start on Cloud Run!",
54 * },
55 * });
56 * ```
57 *
58 * **Example:** Read An Environment Variable From A Server Function
59 * ```typescript
60 * // src/routes/index.tsx
61 * const getGreeting = createServerFn({ method: "GET" }).handler(
62 * () => process.env.GREETING ?? "Hello!",
63 * );
64 * ```
65 *
66 * @resource
67 * @product Website
68 */
69export const TanStackStart = (id: string, props: TanStackStartProps = {}) =>
70 frameworkSite(id, props, {
71 name: "TanStackStart",
72 framework: TANSTACK_START_FRAMEWORK_SPECIFIER,
73 target: TANSTACK_START_NODE_TARGET_SPECIFIER,
74 });