| 1 | # Cloudflare Website: SvelteKit |
| 2 | |
| 3 | Deploys a SvelteKit app to Cloudflare Workers with `Cloudflare.Website.SvelteKit` — no `svelte.config.js`, no `@sveltejs/adapter-cloudflare`, no Wrangler. |
| 4 | |
| 5 | The resource builds the app with SvelteKit's own Vite pipeline and a wrangler-free in-memory Cloudflare adapter, re-bundles the server output for workerd, and deploys client assets + prerendered pages as Worker static assets. Values passed via `env` are exposed to server routes through `platform.env`. |
| 6 | |
| 7 | ```ts |
| 8 | const site = yield* Cloudflare.Website.SvelteKit("SvelteKitSite", { |
| 9 | env: { |
| 10 | GREETING: "Hello from SvelteKit on Cloudflare!", |
| 11 | }, |
| 12 | }); |
| 13 | ``` |
| 14 | |
| 15 | ## Commands |
| 16 | |
| 17 | ```sh |
| 18 | bun alchemy deploy # build + deploy |
| 19 | bun alchemy dev # SvelteKit's Vite dev server (Node SSR, HMR) |
| 20 | bun alchemy destroy # tear down |
| 21 | ``` |
| 22 | |
| 23 | ## Notes |
| 24 | |
| 25 | - `@alchemy.run/frontend-frameworks` must be installed in the project — the Worker's source provider is loaded from its `/sveltekit` export at deploy time. |
| 26 | - Unchanged projects skip the build and deploy entirely (the project tree is content-hashed, respecting `.gitignore`). |
| 27 | - In `alchemy dev`, `platform.env` carries the Worker's real Cloudflare bindings (KV, R2, D1, ...) served by the cloudflare-runtime platform proxy, with literal `env` values (strings and secrets) overlaid. |