Prisma Next is in early access.Read the docs
NextRuntimes

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 deno

Pick 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 install

2. 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 init

The 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):

src/index.ts
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 dev
created user grace+1783380988819@prisma.io
there are now 3 users

Common gotchas

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

On this page