The HTTP Bridge to PostgreSQL for Serverless & Edge
Run PostgreSQL queries over standard stateless HTTPS
fetch() without driver dependencies. Keep reusable connection pools alive, enforce least-privilege role scopes, and execute atomic multi-statement transactions with full idempotency guarantees.Engineered for Modern Cloud & Edge Architectures
Solve direct database connection limits and distributed secret exposure with a secure, long-running gateway process.
Quick Integration
Execute queries from any serverless environment using standard fetch() in just a few lines of code.
// Minimal serverless client with timeout handling
export async function queryPostgres(sql: string, params: unknown[] = []) {
const res = await fetch(`${process.env.PG_GATEWAY_URL}/query`, {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': process.env.PG_GATEWAY_API_KEY!,
'x-database': process.env.PG_GATEWAY_DATABASE!,
},
body: JSON.stringify({ query: sql, parameters: params }),
})
const payload = await res.json()
if (!res.ok) throw new Error(payload.error?.code ?? `HTTP_${res.status}`)
return payload.data
}