1import { frameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
2
3/** The framework-integration package that drives the SolidStart build. */
4export const SOLIDSTART_FRAMEWORK_SPECIFIER =
5 "@alchemy.run/frontend-frameworks/solidstart";
6
7/** The Node container deploy target for the SolidStart build. */
8export const SOLIDSTART_NODE_TARGET_SPECIFIER =
9 "@alchemy.run/frontend-frameworks/solidstart/node";
10
11export interface SolidStartProps extends FrameworkSiteProps {
12 /**
13 * Nitro options forwarded into the nitro plugin the integration appends
14 * (prerendering, route rules, storage, ...). `preset` is owned by the
15 * Node deploy target and may not be set here. JSON-serializable values
16 * only — no functions or plugin instances.
17 *
18 * This is a prop (rather than project config) because the integration
19 * owns the nitro plugin instance: a `nitroV2Plugin()` in your project's
20 * `vite.config.*` is rejected, so this prop is the one home for nitro
21 * options — and it accepts values derived from other resources' Outputs,
22 * which a config file cannot.
23 */
24 nitro?: Record<string, unknown>;
25}
26
27/**
28 * Deploy a [SolidStart](https://start.solidjs.com) application to Cloud Run: the
29 * SSR server in a Cloud Run container, static assets (prerendered pages included)
30 * baked into the image, served assets-first then the framework handler.
31 *
32 * The build runs through `@alchemy.run/frontend-frameworks/solidstart` with
33 * the `@alchemy.run/frontend-frameworks/solidstart/node` deploy target —
34 * both must be installed in your project, alongside `@solidjs/start` and
35 * `@solidjs/vite-plugin-nitro-2`.
36 *
37 * Your `vite.config.ts` needs no adapter wiring: the integration drives the
38 * project's own `vite build` and appends its own nitro plugin instance
39 * carrying nitro's `node` preset.
40 *
41 *
42 * ### Creating SolidStart Sites
43 * **Example:** Basic SolidStart App
44 * ```typescript
45 * const site = yield* GCP.Website.SolidStart("Web", {
46 * rootDir: "./app",
47 * });
48 * ```
49 *
50 * **Example:** Warm Instance with More Memory
51 * ```typescript
52 * const site = yield* GCP.Website.SolidStart("Web", {
53 * rootDir: "./app",
54 * scaling: { minInstanceCount: 1 },
55 * resources: { limits: { cpu: "1", memory: "1Gi" } },
56 * });
57 * ```
58 *
59 * ### Server Configuration
60 * **Example:** Process Environment
61 * ```typescript
62 * const site = yield* GCP.Website.SolidStart("Web", {
63 * rootDir: "./app",
64 * env: {
65 * GREETING: "Hello from SolidStart on Cloud Run!",
66 * },
67 * });
68 * ```
69 *
70 * ### Prerendering
71 * The integration owns the nitro plugin instance (a `nitroV2Plugin()` in
72 * your `vite.config.*` is rejected), so nitro options — prerendering
73 * included — go on the `nitro` prop. Prerendered pages are baked into the
74 * image and served as static files.
75 *
76 * **Example:** Prerender Routes
77 * ```typescript
78 * const site = yield* GCP.Website.SolidStart("Web", {
79 * rootDir: "./app",
80 * nitro: { prerender: { routes: ["/", "/about"] } },
81 * });
82 * ```
83 *
84 * @resource
85 * @product Website
86 */
87export const SolidStart = (id: string, props: SolidStartProps = {}) =>
88 frameworkSite(id, props, {
89 name: "SolidStart",
90 framework: SOLIDSTART_FRAMEWORK_SPECIFIER,
91 target: SOLIDSTART_NODE_TARGET_SPECIFIER,
92 options: { nitro: props.nitro },
93 });