# Deno (/docs/guides/next/runtimes/deno)

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

Run Prisma Next on Deno, including the import-extension and permission differences that matter.

Location: Guides > Next > Runtimes > Deno

## Introduction [#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](https://www.prisma.io/docs/guides/next/runtimes/bun) 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 [#prerequisites]

* [Deno](https://deno.com/) 2.0 or later (`deno --version`)
* A PostgreSQL connection string, or nothing at all: the scaffold can create a [Prisma Postgres](https://www.prisma.io/docs/postgres) database for you

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

`create-prisma` supports Deno as a package manager choice:

```bash
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.

```bash
cd my-deno-app
deno install
```

## 2. Emit the contract and initialize the database [#2-emit-the-contract-and-initialize-the-database]

```bash
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 [#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`):

```ts title="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 [#4-run-it]

```bash
deno task dev
```

```text no-copy
created user grace+1783380988819@prisma.io
there are now 3 users
```

## Common gotchas [#common-gotchas]

> [!WARNING]
> 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 [#prompt-your-coding-agent]

The scaffold installs [Prisma Next skills](https://www.prisma.io/docs/ai/tools/skills#available-skills-for-prisma-next) 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 [#next-steps]

* [Learn the fundamentals](https://www.prisma.io/docs/orm/next/fundamentals/reading-data): filtering, sorting, pagination, and writes.
* [Read the Prisma Next overview](https://www.prisma.io/docs/orm/next) for the concepts behind contracts and typed queries.
* [Use the Bun guide](https://www.prisma.io/docs/guides/next/runtimes/bun) if you also target Bun; the flow is the same apart from the runtime differences above.

## Related pages

- [`Bun`](https://www.prisma.io/docs/guides/next/runtimes/bun): Scaffold a Prisma Next app with Bun, initialize your database, and run your first typed query.