1import * as Namespace from "../../Namespace.ts";
2import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
3
4/** The framework-integration package that drives the SvelteKit build. */
5export const SVELTEKIT_FRAMEWORK_SPECIFIER =
6 "@alchemy.run/frontend-frameworks/sveltekit";
7
8/** The Node container deploy target for the SvelteKit build. */
9export const SVELTEKIT_NODE_TARGET_SPECIFIER =
10 "@alchemy.run/frontend-frameworks/sveltekit/node";
11
12export interface SvelteKitProps extends FrameworkSiteProps {
13 /**
14 * SvelteKit configuration passed to the `sveltekit(config)` Vite plugin.
15 * The `adapter` field is injected by the Node deploy target and may not
16 * be set here. Must be JSON-serializable (it persists in state).
17 */
18 kit?: Record<string, unknown>;
19}
20
21/**
22 * Deploy a SvelteKit application to a Hetzner Cloud Server: kit's SSR
23 * server as a systemd unit on port 3000, static assets (prerendered
24 * pages included) baked into the unit.
25 *
26 * The build runs through `@alchemy.run/frontend-frameworks/sveltekit` with
27 * the `@alchemy.run/frontend-frameworks/sveltekit/node` deploy target.
28 *
29 *
30 * ### Creating SvelteKit Sites
31 * **Example:** Basic SvelteKit App
32 * ```typescript
33 * const site = yield* Hetzner.Website.SvelteKit("Web", {
34 * rootDir: "./app",
35 * });
36 * ```
37 *
38 * **Example:** Custom Domain
39 * ```typescript
40 * const site = yield* Hetzner.Website.SvelteKit("Web", {
41 * rootDir: "./app",
42 * domain: "app.example.com",
43 * zone,
44 * });
45 * ```
46 *
47 * @resource
48 * @product Website
49 */
50export const SvelteKit = (id: string, props: SvelteKitProps = {}) =>
51 makeFrameworkSite(id, props, {
52 name: "SvelteKit",
53 framework: SVELTEKIT_FRAMEWORK_SPECIFIER,
54 target: SVELTEKIT_NODE_TARGET_SPECIFIER,
55 options: props.kit ? { kit: props.kit } : undefined,
56 }).pipe(Namespace.push(id));