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