TypeScript ORM with zero-cost type-safety for your database

Query data from MySQL, PostgreSQL & SQL Server databases with Prisma – a type-safe TypeScript ORM for Node.js

Why Prisma and TypeScript?

Type-safe database client

Prisma Client ensures fully type-safe database queries so that you never write an invalid query

Optimized database queries

Prisma's built-in dataloader ensures optimized and performant database queries, even for N+1 queries.

Autocompletion

Prisma helps you write your queries with rich autocompletion as you write queries

Type inference

Queries with Prisma Client always have their return type inferred making it easy to reason about your data.

Easy database migrations

Map your Prisma schema to the database so you don't need to write SQL to manage your database schema.

Filters, pagination & ordering

Prisma Client reduces boilerplates by providing convenient APIs for common database features.

How Prisma and TypeScript fit together

TypeScript is a statically typed language which builds on JavaScript. It provides you with all the functionality of JavaScript with the additional ability to type and verify your code which saves you time by catching errors and providing fixes before you run your code. Prisma is an ORM for Node.js and TypeScript that gives you the benefits of type-safety at zero cost by auto-generating types from your database schema.

Zero-cost type-safety

Queries with Prisma Client always have their return type inferred making it easy to reason about the returned data – even when you fetch relations.

// Inferred type:
// User & {
//   posts: Post[];
// }
const user = await prisma.user.create({
  data: {
    email: 'alice@prisma.io',
    password: '0ee4808f893b8e05bdd251048d5c4c8af8bb89403676dda95619841a481f8e87',
    name: 'Alice',
    posts: {
      create: {
        title: 'Learn how to use Prisma with TypeScript',
        content: 'https://www.prisma.io/docs/',
      },
    },
  },
  include: {
    posts: true,
  },
})

Generated TypeScript Types for your database tables

Prisma keeps your TypeScript types in sync with the database schema. Below are the types generated by Prisma from the Prisma schema.

type User = {
  id: string
  email: string
  password: string
  name: string | null
}

export type Post = {
  id: string
  createdAt: Date
  title: string
  content: string | null
  authorId: string
}

Our TypeScript Resources

TypeScript Berlin Meetup

The TypeScript Berlin Meetup started in 2019 and is one of the most popular TypeScript Meetups in the world.

Prisma TypeScript examples

Ready-to-run example projects using Prisma, TypeScript and a variety of different frameworks and API technologies