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 Fly:
15 * the SSR server on a Machine, 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 port 3000.
28 *
29 *
30 * ### Creating TanStack Start Sites
31 * **Example:** Basic TanStack Start App
32 * ```typescript
33 * const site = yield* Fly.Website.TanStackStart("Web", {
34 * rootDir: "./app",
35 * });
36 * ```
37 *
38 * **Example:** Custom Domain
39 * ```typescript
40 * const site = yield* Fly.Website.TanStackStart("Web", {
41 * rootDir: "./app",
42 * domain: "app.example.com",
43 * });
44 * ```
45 *
46 * ### Server Configuration
47 * **Example:** Process Environment
48 * ```typescript
49 * const site = yield* Fly.Website.TanStackStart("Web", {
50 * rootDir: "./app",
51 * env: {
52 * GREETING: "Hello from TanStack Start on Fly!",
53 * },
54 * });
55 * ```
56 *
57 * **Example:** Read An Environment Variable From A Server Function
58 * ```typescript
59 * // src/routes/index.tsx
60 * const getGreeting = createServerFn({ method: "GET" }).handler(
61 * () => process.env.GREETING ?? "Hello!",
62 * );
63 * ```
64 *
65 * @resource
66 * @product Website
67 */
68export const TanStackStart = (id: string, props: TanStackStartProps = {}) =>
69 frameworkSite(id, props, {
70 name: "TanStackStart",
71 framework: TANSTACK_START_FRAMEWORK_SPECIFIER,
72 target: TANSTACK_START_NODE_TARGET_SPECIFIER,
73 });