r/SQL • • 1d ago

PostgreSQL Self-hosted alternative to Neon's HTTP driver: query your own Postgres via fetch()

Connecting serverless and edge functions to self-hosted PostgreSQL can be tricky. Some runtimes have TCP limitations, and opening database connections on every invocation adds overhead.

Neon offers an HTTP driver for its platform, so I built HTTP PostgreSQL Gateway for self-hosted PostgreSQL.

It runs alongside your database and lets you query it using plain fetch().

  • Persistent PostgreSQL connection pooling
  • Scoped API keys mapped to PostgreSQL roles
  • Async queries for long-running operations, so functions don't have to wait for results
  • Atomic batches and transactions

It doesn't replace PostgreSQL or make queries faster. It handles connections and execution outside your serverless functions.

Security: It accepts client-supplied SQL, so use least-privilege roles and restrict network access. The project is new and hasn't had much external review yet.

Repo: https://github.com/http-postgres/http-postgres

How are you connecting self-hosted PostgreSQL to serverless or edge functions today? Feedback welcome.

3 Upvotes

2 comments sorted by

1

u/Aggravating-Stage269 15h ago

Mapping API keys straight to Postgres roles is a nice touch, way better than one god key with row checks bolted on later

1

u/Savings-Feedback6581 1h ago

hope you liked it