Waddler <> Supabase
This guide assumes familiarity with:
- Database connection basics with Waddler
- Waddler PostgreSQL drivers - docs
According to the official website, Supabase is an open source Firebase alternative for building secure and performant Postgres backends with minimal configuration.
Step 1 - Install packages
npm
yarn
pnpm
bun
npm i waddler postgres
Step 2 - Initialize the driver and make a query
import { waddler } from 'waddler/postgres-js'
const sql = waddler(process.env.DATABASE_URL);
const result = await sql`select 1;`;
If you need to provide your existing driver:
import { waddler } from 'waddler/postgres-js'
import postgres from 'postgres'
const client = postgres(process.env.DATABASE_URL)
const sql = waddler({ client });
const result = await sql`select 1;`;
If you decide to use connection pooling via Supabase (described here), and have “Transaction” pool mode enabled, then ensure to turn off prepare, as prepared statements are not supported.
import { waddler } from 'waddler/postgres-js'
import postgres from 'postgres'
// Disable prefetch as it is not supported for "Transaction" pool mode
const client = postgres(process.env.DATABASE_URL, { prepare: false })
const sql = waddler({ client });
const result = await sql`select 1;`;
Connect to your database using the Connection Pooler for serverless environments, and the Direct Connection for long-running servers.