Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Neon · Const

Drizzle integration

Drizzle integrates with Neon by using Neon's serverless driver as Drizzle's database backend. In serverless applications, create a client with @neondatabase/serverless and pass it to Drizzle's Neon HTTP adapter.

How it works

Drizzle connects to Neon through the @neondatabase/serverless driver. For serverless runtimes, create a Neon SQL client from DATABASE_URL, then provide it to Drizzle through drizzle-orm/neon-http; the resulting client exposes Drizzle's typed query API.

Syntax

const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql);

Parameters

NameTypeDescription
DATABASE_URLstringNeon database connection string supplied through the DATABASE_URL environment variable.

Returns

A Drizzle database client configured to issue queries through Neon's serverless driver.

Key points

  • Drizzle is a TypeScript ORM that provides a type-safe interface for interacting with a Neon PostgreSQL database.
  • The Neon HTTP integration is intended for serverless deployments, including platforms such as Vercel and Netlify.
  • Import Drizzle's Neon HTTP adapter from drizzle-orm/neon-http when using the serverless HTTP client.
  • Build the Neon SQL client from the DATABASE_URL environment variable before initializing Drizzle.
  • Initialize the Drizzle database object by passing the Neon SQL client to drizzle.
  • Obtain the database connection string from the Neon Console's Connect flow and store it in the application's environment.

Common mistakes

  • Choose the HTTP driver for serverless environments such as Vercel or Netlify; use the WebSocket option when that connection model is required.
  • Do not use a TCP-based PostgreSQL driver in runtimes that cannot open TCP sockets; use Neon's serverless driver instead.

Example: Connect Drizzle to Neon over HTTP

import 'dotenv/config';
import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';

const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql);

const result = await db.select().from(users);
console.log(result);

Creates a Neon serverless SQL client and passes it to Drizzle's Neon HTTP adapter for a query.

When to use it

Run database queries from runtimes that use HTTP rather than TCP.

Edge or serverless application

Use typed, SQL-shaped Drizzle queries against a Neon Postgres database.

TypeScript application

Pair the runtime integration with Drizzle Kit for migration workflows.

Application with schema changes

Interview questions

QHow do you connect Drizzle to Neon in a serverless TypeScript application?

Use neon from @neondatabase/serverless to create a SQL client from DATABASE_URL, then pass that client to drizzle imported from drizzle-orm/neon-http. This gives the application a Drizzle client backed by Neon's HTTP driver.

Follow-up: Which runtime constraint motivates this adapter? Runtimes such as edge functions may not support opening TCP sockets, so the HTTP-based serverless driver is appropriate.

QWhich packages and configuration are needed?

Install drizzle-orm and @neondatabase/serverless; install drizzle-kit separately when migrations are needed. The connection string is supplied through the DATABASE_URL environment variable.

Follow-up: Why keep Drizzle Kit separate? It is the development CLI used for schema and migration workflows, rather than the runtime query client.

QWhich connection drivers does the integration support?

The guide presents several driver choices: Neon serverless HTTP, Neon WebSocket, node-postgres, and postgres.js. Select the driver according to the application's runtime and connection requirements.

Follow-up: What is the key alternative for an environment needing WebSockets? Install the WebSocket support and configure Drizzle with the corresponding Neon WebSocket integration.

  • @neondatabase/serverless
  • drizzle-orm/neon-http
  • drizzle-kit
  • Neon WebSocket driver
  • node-postgres
  • postgres.js

Source: Connect from Drizzle to Neon - Neon Docs. Checked 2026-10-16.