Waddler <> Vercel Postgres
- Database connection basics with Waddler
- Vercel Postgres database - website
- Vercel Postgres driver - docs & GitHub
- Waddler PostgreSQL drivers - docs
According to their official website, Vercel Postgres is a serverless SQL database designed to integrate with Vercel Functions.
Waddler natively supports both @vercel/postgres serverless
driver with waddler/vercel-postgres
package and postgres or pg
drivers to access Vercel Postgres through postgesql://
Step 1 - Install packages
npm i waddler @vercel/postgres
Step 2 - Prepare Vercel Postgres
Setup a project according to the official docs.
Step 3 - Initialize the driver and make a query
import { waddler } from 'waddler/vercel-postgres';
const sql = waddler();
const result = await sql`select 1;`;
If you need to provide your existing driver:
import { sql as vercelSql } from '@vercel/postgres';
import { waddler } from 'waddler/vercel-postgres';
const sql = waddler({ client: vercelSql })
const result = await sql`select 1;`;
With @vercel/postgres severless package you can access Vercel Postgres from either serverful or serverless environments with no TCP available, like Cloudflare Workers, through websockets.
If you’re about to use Vercel Postgres from a serverfull environment, you can do it
either with @vercel/postgres
or directly access the DB through postgesql://
with
either postgres or pg.