Deno
Run Prisma Next on Deno, including the import-extension and permission differences that matter.
Introduction
In this guide, you scaffold a Prisma Next project for Deno, initialize a PostgreSQL database, and run your first typed query. Deno runs TypeScript natively and installs npm packages on demand, so the flow is close to the Bun guide with two Deno-specific differences this guide calls out: explicit import extensions and permission flags.
Every command and code sample below was run end to end against a live Prisma Postgres database.
Prerequisites
- Deno 2.0 or later (
deno --version) - A PostgreSQL connection string, or nothing at all: the scaffold can create a Prisma Postgres database for you
1. Scaffold the project
create-prisma supports Deno as a package manager choice:
deno run -A npm:create-prisma@next create my-deno-app --provider postgres --package-manager denoPick Prisma Postgres at the database prompt to have a database created for you, or paste your own DATABASE_URL. The generated package.json scripts wrap every command in deno run -A --env-file=.env, so environment variables load without a dotenv import.
cd my-deno-app
deno install2. Emit the contract and initialize the database
deno run -A --env-file=.env npm:prisma-next contract emit
deno run -A --env-file=.env npm:prisma-next db initThe first command compiles src/prisma/contract.prisma into the contract your queries are type-checked against. The second creates the tables and signs the database.
The -A flag grants the permissions the CLI needs (network for the database, filesystem for the generated files). To scope permissions tighter, start from --allow-net --allow-read --allow-write --allow-env and adjust to your setup.
3. Write your first query
Replace src/index.ts. Two things to notice: Deno requires the .ts extension on relative imports, and model access is namespace-qualified on PostgreSQL (db.orm.public.User):
import { db } from "./prisma/db.ts";
// Create a user, then read every user back
const user = await db.orm.public.User.create({
email: `grace+${Date.now()}@prisma.io`,
name: "Grace Hopper",
});
console.log(`created user ${user.email}`);
const users = await db.orm.public.User.select("id", "email", "name").all();
console.log(`there are now ${users.length} users`);
await db.close();If you see Module not found "file:///…/src/prisma/db", the import is missing its .ts extension. Deno does not resolve relative imports without an extension.
4. Run it
deno task devcreated user grace+1783380988819@prisma.io
there are now 3 usersCommon gotchas
Deno reports Unsupported compiler options in tsconfig.json for a few options the scaffold sets for Node compatibility. The warning is harmless: Deno ignores those options and runs the code the same way.
Prompt your coding agent
The scaffold installs Prisma Next skills for your coding agent. Prompts that map to this guide:
- "Using the prisma-next-queries skill, add a Deno task that prints every user created in the last day."
- "Tighten the Deno permissions for this project from -A to an explicit allow list."
Next steps
- Learn the fundamentals: filtering, sorting, pagination, and writes.
- Read the Prisma Next overview for the concepts behind contracts and typed queries.
- Use the Bun guide if you also target Bun; the flow is the same apart from the runtime differences above.