Skip to content

Commit 138b184

Browse files
docs: restore verified Prisma 8 Deno guide
1 parent e511ac4 commit 138b184

5 files changed

Lines changed: 154 additions & 2 deletions

File tree

apps/docs/content/docs/(index)/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Use the installed Prisma 8 skills and the current Prisma docs: https://www.prism
6363

6464
</GetStartedTabs>
6565

66-
<SectionRow title="Pick your framework" description="Every guide runs the same journey with the same commands: scaffold, connect Prisma Postgres, run a real query, and deploy. SvelteKit doesn't deploy to Compute yet, so its guide stops at a verified local run.">
66+
<SectionRow title="Pick your framework" description="Every guide runs the same journey with the same commands: scaffold, connect Prisma Postgres, run a real query, and deploy. SvelteKit and Deno don't deploy to Compute yet; their guides stop at a verified local run.">
6767

6868
<IconGrid columns={3}>
6969
<IconLink href="/guides/v8/frameworks/nextjs" title="Next.js" src="/img/technologies/nextjs.svg" invertDark />
@@ -75,6 +75,7 @@ Use the installed Prisma 8 skills and the current Prisma docs: https://www.prism
7575
<IconLink href="/guides/v8/frameworks/sveltekit" title="SvelteKit" src="/img/technologies/sveltekit.svg" />
7676
<IconLink href="/guides/v8/runtimes/bun" title="Bun" src="/img/technologies/bun.svg" />
7777
<IconLink href="/guides/v8/frameworks/elysia" title="Elysia" mono="E" />
78+
<IconLink href="/guides/v8/runtimes/deno" title="Deno" src="/img/technologies/deno.svg" invertDark />
7879
</IconGrid>
7980

8081
If you're using Express or another Node.js server, follow the [existing-project path](/v8/add-to-existing-project/postgresql) instead.

apps/docs/content/docs/(index)/v8/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Each guide runs the same journey for a specific framework: scaffold, connect Pri
7272
<IconLink href="/guides/v8/frameworks/sveltekit" title="SvelteKit" src="/img/technologies/sveltekit.svg" />
7373
<IconLink href="/guides/v8/runtimes/bun" title="Bun" src="/img/technologies/bun.svg" />
7474
<IconLink href="/guides/v8/frameworks/elysia" title="Elysia" mono="E" />
75+
<IconLink href="/guides/v8/runtimes/deno" title="Deno" src="/img/technologies/deno.svg" invertDark />
7576
</IconGrid>
7677

7778
## Learn the fundamentals

apps/docs/content/docs/guides/v8/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Each framework guide scaffolds a working app with `create-prisma`, initializes t
2929

3030
<Cards>
3131
<Card href="/guides/v8/runtimes/bun" title="Bun" />
32+
<Card href="/guides/v8/runtimes/deno" title="Deno" />
3233
</Cards>
3334

3435
## Coming as they land
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
title: Deno
3+
description: Run a minimal Prisma 8 and PostgreSQL app on Deno.
4+
url: /guides/v8/runtimes/deno
5+
metaTitle: How to use Prisma 8 with Deno
6+
metaDescription: Scaffold a Prisma 8 project for Deno, initialize Prisma Postgres, and run the generated typed query end to end.
7+
---
8+
9+
## Introduction
10+
11+
In this guide, you scaffold a minimal Prisma 8 app for Deno, initialize a PostgreSQL database, and run the generated typed query. The app uses Deno-native tasks and explicit `.ts` extensions for relative imports.
12+
13+
Every command below was run end to end against a live Prisma Postgres database.
14+
15+
## Prerequisites
16+
17+
- [Deno](https://deno.com/) 2.0 or later (`deno --version`)
18+
19+
## Use with your agent
20+
21+
Prefer to delegate this guide? Copy this prompt and hand it to your coding agent:
22+
23+
<AgentPrompt>
24+
25+
```text
26+
Create and verify a minimal Prisma 8 app on Deno.
27+
28+
1. Run `deno run -A npm:create-prisma@latest my-deno-app --template minimal --provider postgres --package-manager deno --no-deploy --yes`.
29+
2. Enter `my-deno-app`. Run `deno run -A npm:create-db@latest --env .env --ttl 24h` and show me the claim URL so I can keep the temporary database.
30+
3. Run `deno task db:init`, then start `deno task dev` in the background.
31+
4. Request `http://localhost:3000` and verify that it returns Alice, Bob, and Carol. The first request seeds these users automatically; do not add or run a separate seed command.
32+
5. Do not deploy to Prisma Compute because it does not support Deno.
33+
34+
Use the generated tasks instead of invoking a Prisma CLI package directly.
35+
```
36+
37+
</AgentPrompt>
38+
39+
## 1. Scaffold the project
40+
41+
Run `create-prisma` through Deno and select the minimal PostgreSQL template:
42+
43+
```bash
44+
deno run -A npm:create-prisma@latest my-deno-app --template minimal --provider postgres --package-manager deno --no-deploy
45+
```
46+
47+
The command creates the app, installs its npm dependencies through Deno, and emits the Prisma contract artifacts. Deno support is currently limited to the minimal PostgreSQL template.
48+
49+
```bash
50+
cd my-deno-app
51+
```
52+
53+
The generated project includes:
54+
55+
- `deno.json` with npm compatibility enabled
56+
- Deno-native `dev`, `build`, and Prisma tasks in `package.json`
57+
- explicit `.ts` extensions on relative imports
58+
- no Composer or Prisma Compute deployment files
59+
60+
## 2. Create and initialize the database
61+
62+
Create a temporary Prisma Postgres database and write its connection string to `.env`:
63+
64+
```bash
65+
deno run -A npm:create-db@latest --env .env --ttl 24h
66+
```
67+
68+
The command prints a claim URL. Open it within 24 hours to keep the database, or replace `DATABASE_URL` in `.env` with your own PostgreSQL connection string.
69+
70+
Apply the starter contract and sign the database:
71+
72+
```bash
73+
deno task db:init
74+
```
75+
76+
## 3. Run the app
77+
78+
Start the generated HTTP server:
79+
80+
```bash
81+
deno task dev
82+
```
83+
84+
Then request it from another terminal:
85+
86+
```bash
87+
curl http://localhost:3000
88+
```
89+
90+
The response contains the starter users:
91+
92+
```json no-copy
93+
{
94+
"users": [
95+
{ "email": "alice@prisma.io", "name": "Alice" },
96+
{ "email": "bob@prisma.io", "name": "Bob" },
97+
{ "email": "carol@prisma.io", "name": "Carol" }
98+
]
99+
}
100+
```
101+
102+
The first request runs `src/prisma/seed.ts` through the generated query helper. Seeding is idempotent, so later requests read the same rows without creating duplicates. There is no separate seed command.
103+
104+
## 4. Understand the generated query
105+
106+
The generated `src/prisma/users.ts` connects the database, seeds on the first query, and reads from the PostgreSQL `public` namespace:
107+
108+
```ts title="src/prisma/users.ts"
109+
import { db } from "./db.ts";
110+
import { seed } from "./seed.ts";
111+
112+
export async function listUsers(limit = 10) {
113+
await seed();
114+
115+
const users = await db.orm.public.User
116+
.select("id", "email", "username", "name", "createdAt")
117+
.take(limit)
118+
.all();
119+
120+
return users.map((user) => ({
121+
id: String(user.id),
122+
email: user.email,
123+
username: user.username ?? null,
124+
name: user.name ?? null,
125+
createdAt: user.createdAt,
126+
}));
127+
}
128+
```
129+
130+
Deno requires the `.ts` extension on these relative imports. The generated files already include it.
131+
132+
After changing `src/prisma/contract.prisma`, regenerate the typed artifacts and update the database:
133+
134+
```bash
135+
deno task contract:emit
136+
deno task db:update
137+
```
138+
139+
## Current limitations
140+
141+
- Prisma Compute does not support Deno deployments yet.
142+
- The generated ORM tasks currently use the Deno-compatible Prisma 8 ORM CLI entry point. The consolidated `npm:prisma@next` CLI still loads Node-only credential storage under Deno, so use the generated tasks rather than invoking a CLI package directly.
143+
- The generated commands use `-A` for the filesystem, environment, and network permissions required during setup and local development. You can replace it with a narrower allow list for your application after setup.
144+
145+
## Next steps
146+
147+
- [Learn the fundamentals](/orm/v8/fundamentals/reading-data): filtering, sorting, pagination, and writes.
148+
- [Read the Prisma 8 overview](/orm/v8) for contracts, typed queries, and migrations.
149+
- [Use the Bun guide](/guides/v8/runtimes/bun) if you also target Bun.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "title": "Runtimes", "pages": ["bun"] }
1+
{ "title": "Runtimes", "pages": ["bun", "deno"] }

0 commit comments

Comments
 (0)