Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

I built a Supabase-style query client that talks directly to Postgres

Description and use

pg-fluent lets developers use the Supabase query API directly against PostgreSQL, removing the need for PostgREST and HTTP overhead while preserving all query features and type safety.

Problem

Developers using Supabase JS client want to avoid the overhead of a PostgREST service and the need for a project URL and anon key when they already control a Postgres instance.

Outcome

pg-fluent provides a Supabase‑style query API that runs directly against PostgreSQL, removing the need for a PostgREST service and HTTP requests while retaining all query features, type safety, and optional tracing.

Workflow

  • Install pg-fluent via npm
  • Create a client with createClient({connectionString: process.env.DATABASE_URL})
  • Use the Supabase-like API: db.from('table').select(...).eq(...).order(...).limit(...)
  • Optionally inspect generated SQL with toSQL()
  • Perform transactions with db.transaction(trx => { ... })
  • Execute raw SQL safely with db.sql...
  • Stream rows, use COPY, LISTEN/NOTIFY, or read replicas with .primary()
  • Generate TypeScript types with npx pg-fluent gen-types

Evidence

pg-fluent uses the real @supabase/postgrest-js and hands it a custom fetch.

Source

The whole postgrest-js surface works: filters, or()/not()/filter(), JSON paths like meta->>author, range(), single()/maybeSingle(), count, upsert, rpc, csv(), explain(), and embeds.

Source

The tagged template always binds interpolations as parameters. The only way to run SQL text you built yourself is db.unsafe().

Source

  • Record date: 2026-10-14T21:56:20.356Z