1---
2title: SvelteKit
3description: Deploy SvelteKit to Prisma Compute with Prisma.Website.SvelteKit — SSR and prerendered assets on Bun, with native Vite dev locally.
4sidebar:
5 order: 12
6---
7
8import { Code, Tabs, TabItem } from "@astrojs/starlight/components";
9
10export const devDeps = "@alchemy.run/frontend-frameworks @vercel/nft";
11
12`Prisma.Website.SvelteKit` builds [SvelteKit](https://svelte.dev/docs/kit)
13with its Vite pipeline and an injected Node-target adapter. Client
14assets, prerendered pages, and the server handler are uploaded as a
15`tar.gz` artifact and served on **Bun in Prisma Compute**, not a Node
16container.
17
18## Install
19
20Install the build-time integration; the resource loads its `/sveltekit`
21and `/sveltekit/node` exports from your project:
22
23<Tabs syncKey="pkgManager">
24 <TabItem label="bun" icon="bun"><Code code={`bun add -d ${devDeps}`} lang="sh" /></TabItem>
25 <TabItem label="npm" icon="npm"><Code code={`npm install -D ${devDeps}`} lang="sh" /></TabItem>
26 <TabItem label="pnpm" icon="pnpm"><Code code={`pnpm add -D ${devDeps}`} lang="sh" /></TabItem>
27 <TabItem label="yarn" icon="seti:yarn"><Code code={`yarn add -D ${devDeps}`} lang="sh" /></TabItem>
28</Tabs>
29
30## Configure SvelteKit
31
32This integration follows Kit v3: Kit options live in the
33`sveltekit(...)` call in `vite.config.ts`, not `svelte.config.js`.
34Your config loads natively. Alchemy injects its adapter; don't set
35`kit.adapter`. An adapter declared in the native config is replaced
36with a warning.
37
38## Declare the Website
39
40```typescript
41// alchemy.run.ts
42import * as Prisma from "alchemy/Prisma";
43
44export const Website = Prisma.Website.SvelteKit("Website");
45```
46
47Use `rootDir` for an app outside `.`. Omit `project` to create a
48database-less Prisma project on live deploy, or pass an existing project.
49
50## Add it to the Stack
51
52```typescript
53// alchemy.run.ts
54import * as Alchemy from "alchemy";
55import * as Effect from "effect/Effect";
56
57export default Alchemy.Stack(
58 "MySvelteKitSite",
59 { providers: Prisma.providers(), state: Alchemy.localState() },
60 Effect.gen(function* () {
61 const site = yield* Website;
62 return { url: site.url };
63 }),
64);
65```
66
67Routes with `export const prerender = true` are generated at build
68time and served as files. Server routes and load functions run in the
69Kit handler on Compute. `site.url` is the deployed endpoint.
70
71## Add environment variables
72
73```diff lang="typescript"
74export const Website = Prisma.Website.SvelteKit("Website", {
75+ env: {
76+ GREETING: "Hello from Alchemy!",
77+ API_BASE: "https://api.example.com",
78+ },
79});
80```
81
82Values are applied before build and dev, and passed to Compute. These
83are process environment variables, not Worker bindings.
84
85## Read the environment in server code
86
87```typescript
88// src/routes/+page.server.ts
89export const load = () => ({
90 greeting: process.env.GREETING ?? "hello",
91});
92```
93
94The Bun process exposes `process.env`; Kit's `$env/dynamic/private`
95reads the server environment too. Keep secrets out of public env keys.
96
97## Kit options
98
99Keep Vite plugins and ordinary Kit config in your app:
100
101```typescript
102// vite.config.ts
103import { sveltekit } from "@sveltejs/kit/vite";
104import tailwindcss from "@tailwindcss/vite";
105import { defineConfig } from "vite";
106
107export default defineConfig({
108 plugins: [tailwindcss(), sveltekit({ alias: { $lib: "src/lib" } })],
109});
110```
111
112The serializable `kit` bag overrides those options:
113
114```typescript
115export const Website = Prisma.Website.SvelteKit("Website", {
116 kit: { paths: { base: "/docs" } },
117});
118```
119
120Alchemy owns the adapter in both cases.
121
122## Local dev
123
124`bun alchemy dev` starts SvelteKit's own Vite server with HMR.
125`site.url` is local, and the Website creates no Prisma resources.
126`.pipe(Alchemy.remote())` opts into live deployment during dev.
127
128## Custom domain
129
130```typescript
131const site = yield* Prisma.Website.SvelteKit("Web", {
132 domain: "app.example.com",
133});
134```
135
136This creates `Prisma.CustomDomain`; the app must be on the project's
137current default branch. Configure its returned DNS records yourself
138and check status before cutover. See
139[Custom domains](/prisma/frontend/websites#custom-domains).
140
141## Where next
142
143- [SvelteKit API](/providers/prisma/website/sveltekit).
144- [SvelteKit example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-website-sveltekit).
145- [Websites](/prisma/frontend/websites) and [Compute apps](/prisma/compute/apps).