The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { InputProps } from "alchemy/Input"; |
| 2 | import * as Namespace from "alchemy/Namespace"; |
| 3 | import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts"; |
| 4 | |
| 5 | /** The framework-integration package that drives the SolidStart build. */ |
| 6 | export const SOLIDSTART_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/solidstart"; |
| 7 | |
| 8 | /** The AWS Lambda deploy target for the SolidStart build. */ |
| 9 | export const SOLIDSTART_AWS_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/solidstart/aws"; |
| 10 | |
| 11 | /** The Node deploy target for the Lambda Web Function server (the default). */ |
| 12 | export const SOLIDSTART_WEB_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/solidstart/node"; |
| 13 | |
| 14 | export type SolidStartProps = FrameworkSiteProps<{ |
| 15 | /** |
| 16 | * Nitro options forwarded into the nitro plugin the integration appends |
| 17 | * (prerendering, route rules, storage, ...). `preset` is owned by the |
| 18 | * deploy target and may not be set here. JSON-serializable values only — |
| 19 | * no functions or plugin instances. |
| 20 | * |
| 21 | * This is a prop (rather than project config) because the integration |
| 22 | * owns the nitro plugin instance: a `nitroV2Plugin()` in your project's |
| 23 | * `vite.config.*` is rejected, so this prop is the one home for nitro |
| 24 | * options — and it accepts values derived from other resources' Outputs, |
| 25 | * which a config file cannot. |
| 26 | */ |
| 27 | nitro?: Record<string, unknown>; |
| 28 | }>; |
| 29 | |
| 30 | /** |
| 31 | * Deploy a [SolidStart](https://start.solidjs.com) application to AWS: the |
| 32 | * SSR server on a Lambda Web Function, static assets (prerendered pages |
| 33 | * included) in S3, and a CloudFront distribution whose edge router serves |
| 34 | * uploaded files from S3 and forwards everything else to the server. |
| 35 | * |
| 36 | * The server runs on a Lambda Web Function: the framework's Node server |
| 37 | * (built with the `@alchemy.run/frontend-frameworks/solidstart/node` deploy |
| 38 | * target) serves many requests per environment and streams responses. Set |
| 39 | * `server: "function"` to use a Lambda Function behind a streaming Function |
| 40 | * URL instead, built with the `/aws` target below, for Regions without Web |
| 41 | * Functions. |
| 42 | * |
| 43 | * The build runs through `@alchemy.run/frontend-frameworks/solidstart` with |
| 44 | * the `@alchemy.run/frontend-frameworks/solidstart/aws` deploy target — both |
| 45 | * must be installed in your project, alongside `@solidjs/start` and |
| 46 | * `@solidjs/vite-plugin-nitro-2`. |
| 47 | * |
| 48 | * Your `vite.config.ts` needs no adapter wiring: the integration drives the |
| 49 | * project's own `vite build` and appends its own nitro plugin instance |
| 50 | * carrying nitro's `aws-lambda` preset with response streaming enabled. |
| 51 | * |
| 52 | * ### Creating SolidStart Sites |
| 53 | * **Example:** Basic SolidStart App |
| 54 | * ```typescript |
| 55 | * const site = yield* AWS.Website.SolidStart("Web", { |
| 56 | * rootDir: "./app", |
| 57 | * }); |
| 58 | * ``` |
| 59 | * |
| 60 | * **Example:** Custom Domain |
| 61 | * ```typescript |
| 62 | * const site = yield* AWS.Website.SolidStart("Web", { |
| 63 | * rootDir: "./app", |
| 64 | * domain: { |
| 65 | * name: "app.example.com", |
| 66 | * hostedZoneId: zone.hostedZoneId, |
| 67 | * }, |
| 68 | * }); |
| 69 | * ``` |
| 70 | * |
| 71 | * ### Server Configuration |
| 72 | * **Example:** Tune The Server Function |
| 73 | * ```typescript |
| 74 | * const site = yield* AWS.Website.SolidStart("Web", { |
| 75 | * rootDir: "./app", |
| 76 | * memorySize: 2048, |
| 77 | * env: { |
| 78 | * API_BASE: api.url, |
| 79 | * }, |
| 80 | * }); |
| 81 | * ``` |
| 82 | * |
| 83 | * ### Prerendering |
| 84 | * The integration owns the nitro plugin instance (a `nitroV2Plugin()` in |
| 85 | * your `vite.config.*` is rejected), so nitro options — prerendering |
| 86 | * included — go on the `nitro` prop. Prerendered pages are uploaded to S3 |
| 87 | * and served from the edge automatically. |
| 88 | * |
| 89 | * **Example:** Prerender Routes |
| 90 | * ```typescript |
| 91 | * const site = yield* AWS.Website.SolidStart("Web", { |
| 92 | * rootDir: "./app", |
| 93 | * nitro: { prerender: { routes: ["/", "/about"] } }, |
| 94 | * }); |
| 95 | * ``` |
| 96 | * |
| 97 | * @resource |
| 98 | */ |
| 99 | export const SolidStart = (id: string, props: InputProps<SolidStartProps, "server"> = {}) => { |
| 100 | const p = props as SolidStartProps; |
| 101 | return makeFrameworkSite(id, props, { |
| 102 | name: "SolidStart", |
| 103 | framework: SOLIDSTART_FRAMEWORK_SPECIFIER, |
| 104 | target: SOLIDSTART_AWS_TARGET_SPECIFIER, |
| 105 | webTarget: SOLIDSTART_WEB_TARGET_SPECIFIER, |
| 106 | options: { nitro: p.nitro }, |
| 107 | }).pipe(Namespace.push(id)); |
| 108 | }; |