BetaLenzon is in beta — the Free tier is 100% free while we're in beta (bring your own Anthropic key, public repos).See plans →
Lenzon

prisma/prisma-next — Prisma Next: Contract-First Data Access

prisma/prisma-next ·

Loading…

Transcript

QuickFacts

Welcome to Prisma Next, a fresh take on database ORMs for TypeScript. Instead of generating thousands of lines of code from your schema, it compiles to a lightweight JSON contract and type definitions, then builds queries at runtime. Let's explore how it all works.

QuickFacts

The project is built entirely in TypeScript and organized as a turbo monorepo. It uses arktype for runtime contract validation, pg for talking to Postgres, and a modern toolchain with biome for linting and vitest for testing. There's a strong emphasis on type safety and build performance.

PlainEnglish

Here's the big idea. Traditional ORMs generate entire codebases from your schema at build time. Prisma Next takes a different path. It treats your schema as a versioned data contract, compiling it to a lightweight JSON file and TypeScript definitions. The runtime then builds queries dynamically using that contract.

PlainEnglish

Think of it like this. Traditional ORMs are like printing an entire building from a blueprint every time you compile. Prisma Next just prints a detailed blueprint that the runtime consults as it builds queries. If the schema changes, you print a new blueprint, you don't rebuild the whole building.

Architecture

The architecture flows through three stages. First, you write your schema in PSL or TypeScript. Then the parser and emitter turn it into contract artifacts. Finally at runtime, your queries flow through the query builder, get lowered by an adapter, and execute against the database. It's a clean separation of concerns.

Architecture

The monorepo is organized by layers and domains. Framework packages provide the target-agnostic core. SQL packages add SQL-specific logic like query builders and the runtime. Finally, target packages contain adapters for specific databases like Postgres and SQLite. It's strict layering, which keeps dependencies clean.

PlainEnglish

Let's walk through the developer experience. You start by writing your schema. Then you run the CLI to emit the contract artifacts. In your app, you import those artifacts and initialize the runtime with your database connection. Now you can build type-safe queries using a fluent API. When you execute, the runtime handles all the lowering and codec work behind the scenes.

Architecture

Here's what happens when you execute a query. The SQL builder constructs an abstract syntax tree. The runtime takes that AST and passes it to the adapter, which renders it to actual SQL for your database dialect. The adapter encodes parameters using registered codecs, executes the query, then decodes the wire-format results back to JavaScript types. The runtime returns a fully typed result to your application.

Architecture

Adapters are the bridge between the universal query AST and specific database dialects. Each adapter provides a SQL renderer that knows how to translate AST nodes to that database's syntax. It registers codecs for database-specific types like Postgres timestamptz or jsonb. It also declares capabilities, so the runtime knows what features are available, like lateral joins or returning clauses.

Architecture

The framework supports extension packs that add new capabilities. For example, the pgvector extension registers a vector codec, adds cosine distance operations to the query builder, and defines schema attributes for vector columns. Extensions integrate seamlessly without modifying core framework code. It's all declarative registration.

Community

This is an actively developed project with a recent commit just one day ago. It's currently maintained by a small, focused team, primarily Alberto Schiabel. The repository has three branches and is in active evolution. There are no formal tags yet, which suggests we're looking at an early-stage or pre-release codebase that's still finding its shape.

PlainEnglish

Prisma Next is rethinking how we build database layers in TypeScript. Instead of code generation, it uses contract-first design. Instead of rigid schemas, it offers runtime flexibility. And it maintains strict type safety throughout. If you're building a data-heavy TypeScript app and want something leaner and more composable than traditional ORMs, this is a project worth watching.

How this was made

Lenzon read prisma/prisma-next and generated this walkthrough automatically. The narration above is the transcript of what it says.

Explain a pull request from your own repo

Point Lenzon at a repo or a pull request and get a narrated walkthrough like this one.

Try it