Skip to main content
Drizzle ORM is a TypeScript-first ORM that provides type-safe database access with a SQL-like query builder. You can use Drizzle with Xata using either the standard PostgreSQL driver or the serverless driver for edge environments.

Prerequisites

  • Xata account with a project and branch
  • Node.js project with TypeScript

Installation

Install Drizzle ORM and the PostgreSQL driver:

Get your connection string

Set it as an environment variable:

Connect to Xata

Use this for traditional servers and long-running applications:

Define your schema

Create a schema.ts file:

Query your database

Configure Drizzle Kit

Create a drizzle.config.ts file for migrations:

Run migrations

Generate and apply migrations:
For serverless environments, consider using the Serverless Proxy to connect over HTTP or WebSocket instead of TCP.