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 Fly: the
29 * SSR server on a Machine, 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* Fly.Website.SolidStart("Web", {
46 * rootDir: "./app",
47 * });
48 * ```
49 *
50 * **Example:** Custom Domain
51 * ```typescript
52 * const site = yield* Fly.Website.SolidStart("Web", {
53 * rootDir: "./app",
54 * domain: "app.example.com",
55 * });
56 * ```
57 *
58 * ### Server Configuration
59 * **Example:** Process Environment
60 * ```typescript
61 * const site = yield* Fly.Website.SolidStart("Web", {
62 * rootDir: "./app",
63 * env: {
64 * GREETING: "Hello from SolidStart on Fly!",
65 * },
66 * });
67 * ```
68 *
69 * ### Prerendering
70 * The integration owns the nitro plugin instance (a `nitroV2Plugin()` in
71 * your `vite.config.*` is rejected), so nitro options — prerendering
72 * included — go on the `nitro` prop. Prerendered pages are baked into the
73 * image and served as static files.
74 *
75 * **Example:** Prerender Routes
76 * ```typescript
77 * const site = yield* Fly.Website.SolidStart("Web", {
78 * rootDir: "./app",
79 * nitro: { prerender: { routes: ["/", "/about"] } },
80 * });
81 * ```
82 *
83 * @resource
84 * @product Website
85 */
86export const SolidStart = (id: string, props: SolidStartProps = {}) =>
87 frameworkSite(id, props, {
88 name: "SolidStart",
89 framework: SOLIDSTART_FRAMEWORK_SPECIFIER,
90 target: SOLIDSTART_NODE_TARGET_SPECIFIER,
91 options: { nitro: props.nitro },
92 });