Become a Gold Sponsor

Drizzle <> Neon Postgres

This guide assumes familiarity with:

Drizzle has native support for Neon connections with the neon-http and neon-websockets drivers. These use the neon-serverless driver under the hood.

With the neon-http and neon-websockets drivers, you can access a Neon database from serverless environments over HTTP or WebSockets instead of TCP.
Querying over HTTP is faster for single, non-interactive transactions.

If you need session or interactive transaction support, or a fully compatible drop-in replacement for the pg driver, you can use the WebSocket-based neon-serverless driver.
You can connect to a Neon database directly using Postgres

For an example of using Drizzle ORM with the Neon Serverless driver in a Cloudflare Worker, see here.
To use Neon from a serverful environment, you can use the PostgresJS driver, as described in Neon’s official Node.js docs — see docs.

Step 1 - Install packages

npm
yarn
pnpm
bun
npm i drizzle-orm @neondatabase/serverless
npm i -D drizzle-kit

Step 2 - Initialize the driver and make a query

Neon HTTP
Neon Websockets
node-postgres
postgres.js
import { drizzle } from 'drizzle-orm/neon-http';

const db = drizzle(process.env.DATABASE_URL);

const result = await db.execute('select 1');

If you need to provide your existing drivers:

Neon HTTP
Neon Websockets
node-postgres
postgres.js
import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';

const sql = neon(process.env.DATABASE_URL!);
const db = drizzle({ client: sql });

const result = await db.execute('select 1');

What’s next?