# SvelteKit (/docs/guides/v8/frameworks/sveltekit)

> For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

Set up Prisma 8 in a SvelteKit app with create-prisma, from scaffold to rendered data.

Location: Guides > v8 (RC) > Frameworks > SvelteKit

## Introduction [#introduction]

This guide shows you how to use Prisma 8 in a SvelteKit app. You scaffold a project where a server load function queries your database, initialize the schema, and see your data render.

Every command below was run end to end against a live [Prisma Postgres](https://www.prisma.io/docs/postgres) database.

## Quick start [#quick-start]

One command scaffolds the project with Prisma 8 wired in:

  

#### bun

```bash
bunx create-prisma@next create my-app --template svelte --provider postgres
```

#### pnpm

```bash
pnpm dlx create-prisma@next create my-app --template svelte --provider postgres
```

#### yarn

```bash
yarn dlx create-prisma@next create my-app --template svelte --provider postgres
```

#### npm

```bash
npx create-prisma@next create my-app --template svelte --provider postgres
```

Answer the prompts, then export `DATABASE_URL` in your shell before running the database scripts. Need a database? `npx create-db@latest` prints a Prisma Postgres connection string.

## Prerequisites [#prerequisites]

* [Node.js](https://nodejs.org) 24 or later
* A PostgreSQL connection string, or nothing at all: `npx create-db@latest` can create a Prisma Postgres database for you

## Use with your agent [#use-with-your-agent]

Prefer to delegate this guide? Copy the prompt and hand it to your coding agent:

```text
Create a new SvelteKit app with Prisma 8, seed it, and verify the page renders.

1. Scaffold: `npx create-prisma@next create my-app --template svelte --provider postgres --yes`. Then get a database connection string: use the one I give you, or create a Prisma Postgres database with `npx create-db@latest` and show me the claim URL it prints. Export it as `DATABASE_URL` in the shell and write it to `my-app/.env` for the deploy step; the generated scripts read the environment variable, not `.env`.
2. In `my-app`, run `npm run db:init` with `DATABASE_URL` exported. Sample users are seeded automatically on the app's first query; there is no separate seed script.
3. Do not deploy to Prisma Compute; it does not support SvelteKit yet. Start `npm run dev` in the background, wait until it reports ready, verify http://localhost:5173 lists the three seeded users, then stop the dev server, following https://www.prisma.io/docs/guides/v8/frameworks/sveltekit.md.

Use the installed Prisma 8 skills.
```

## 1. Scaffold and enter the project [#1-scaffold-and-enter-the-project]

  

#### bun

```bash
bunx create-prisma@next create my-app --template svelte --provider postgres
cd my-app
```

#### pnpm

```bash
pnpm dlx create-prisma@next create my-app --template svelte --provider postgres
cd my-app
```

#### yarn

```bash
yarn dlx create-prisma@next create my-app --template svelte --provider postgres
cd my-app
```

#### npm

```bash
npx create-prisma@next create my-app --template svelte --provider postgres
cd my-app
```

The scaffold generates the SvelteKit app with Prisma 8 wired in, installs dependencies, and emits the contract your queries are type-checked against.

Next, set the database connection. Use your own PostgreSQL connection string, or create a Prisma Postgres database with `npx create-db@latest`; it prints a connection string and a claim URL you can open to keep the database. Export the variable, and write it to `.env` for the deploy step later. The generated scripts read the environment variable, not `.env`:

```bash
export DATABASE_URL="<your connection string>"
echo "DATABASE_URL=\"$DATABASE_URL\"" > .env
```

## 2. Initialize the database [#2-initialize-the-database]

  

#### bun

```bash
bun run db:init
```

#### pnpm

```bash
pnpm run db:init
```

#### yarn

```bash
yarn db:init
```

#### npm

```bash
npm run db:init
```

```text no-copy
"summary": "Applied 5 operation(s) across 1 space(s), database signed"
```

`db:init` applies your schema (`src/prisma/contract.prisma`) to the database and signs it. Sample users are seeded automatically the first time the app queries the database.

## 3. Run and verify [#3-run-and-verify]

  

#### bun

```bash
bun run dev
```

#### pnpm

```bash
pnpm run dev
```

#### yarn

```bash
yarn dev
```

#### npm

```bash
npm run dev
```

Open [http://localhost:5173](http://localhost:5173). The page lists the seeded users, loaded on the server by the `+page.server.ts` load function.

## Where things live [#where-things-live]

* `src/routes/+page.server.ts`: the server `load` function that fetches users
* `src/routes/+page.svelte`: the page that renders them
* `src/prisma/users.ts`: the `listUsers` query helper the load function imports
* `src/prisma/db.ts`: the Prisma 8 client behind that helper

Model access is namespace-qualified on PostgreSQL: `db.orm.public.User`. The [Prisma 8 overview](https://www.prisma.io/docs/orm/v8) covers the contract-first model behind it.

[Prisma Compute](https://www.prisma.io/docs/compute) does not support SvelteKit deployments yet; see [Deploy your first app](https://www.prisma.io/docs/prisma-compute/deploy) for what is currently supported. In the meantime, the app deploys to SvelteKit's usual hosts through its standard adapters.

## Next steps [#next-steps]

* Change the schema in `src/prisma/contract.prisma`, then run `npm run contract:emit` and `npm run db:update`.
* [Learn the fundamentals](https://www.prisma.io/docs/orm/v8/fundamentals/reading-data): filtering, sorting, pagination, and writes.
* [Read the Prisma 8 overview](https://www.prisma.io/docs/orm/v8) for the concepts behind contracts and typed queries.

## Related pages

- [`Astro`](https://www.prisma.io/docs/guides/v8/frameworks/astro): Set up Prisma 8 in an Astro app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.
- [`Elysia`](https://www.prisma.io/docs/guides/v8/frameworks/elysia): Build an Elysia API on Prisma 8 with the elysia template and deploy it to Prisma Compute.
- [`Hono`](https://www.prisma.io/docs/guides/v8/frameworks/hono): Build a Hono API on Prisma 8 with the hono template, add your own routes, and deploy it to Prisma Compute.
- [`NestJS`](https://www.prisma.io/docs/guides/v8/frameworks/nestjs): Set up Prisma 8 in a NestJS app with create-prisma, from scaffold to seeded API to a live deploy on Prisma Compute.
- [`Next.js`](https://www.prisma.io/docs/guides/v8/frameworks/nextjs): Set up Prisma 8 in a Next.js app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.