Neon
According to their official website (opens in a new tab), Neon database is a multi-cloud fully managed Postgres.
Drizzle ORM natively supports both Neon Serverless (opens in a new tab)
driver with drizzle-orm/neon-serverless
package and postgres
or pg
drivers to access Neon database, as of their official nodejs docs (opens in a new tab)
npm i drizzle-orm @neondatabase/serverless
npm i -D drizzle-kit
With Neon Serverless package [github (opens in a new tab), blog post (opens in a new tab)] you can access Neon database from serverless environments with no TCP available, like Cloudflare Workers, through websockets.
Below is the example of using Drizzle ORM with Neon Serverless driver in Cloudflare Worker, for extensive example - see here (opens in a new tab)
import { Pool } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-serverless';
export default {
async fetch(req, env, ctx) {
const pool = new Pool({ connectionString: env.DATABASE_URL });
const db = drizzle(pool)
const result = await db.select().from(...);
ctx.waitUntil(pool.end());
return new Response(now);
}
}
If you're about to use Neon from a serverfull environments, according to their official nodejs docs (opens in a new tab) you should just use PostgresJS driver - see docs.