Skip to content

Conversation

@atilafassina
Copy link

@atilafassina atilafassina commented Oct 27, 2025

part of #32

  • Adds serverless client
  • Tests passing locally
  • Add Pooler support
  • Add Client HTTP support
  • Generation connection string when nothing is provided in dev
  • Help tests running in CI
  • Update documentation

This PR introduces 3 integration options.
As opposed to the existing Postgres integration (that works with pg), this one works with Neon's Serverless Driver.
The driver offer 3 connection options.

  1. serverless: is the most recommended and used because it works so well with serverless environments.
  2. Pool is a client that connects via HTTP and WebSockets, it has a few operation differences than a regular client, most noticiable in the code is that it does not need to be disposed.
  3. Client the most similar to the pg connector, this is an HTTP client.

Testing

@pi0 what are your thoughts on testing, the way I see it we have 3 options.

  1. Leverage the get-db library to create and seed a new DB per connector during CI runs. These DBs are ephemeral and need no credentials. (Neon Launchpad
  2. Create an unjs account in Neon and have one DB for each test setup, makes it easier to debug if tests misbehave because we have access to the dashboard.
  3. Mocking.

Imho, the quickest and easiest is number 2. But it requires adding the env_vars to the repository and setting up the account (which I'm more than happy to do and make sure you have access to it).

Going forward for Postgres

Since both the Neon and Postgres connectors work in a very very similar fashion, I'd love to create a postgres/serverless connector and have Neon be an alias to it. So, the way I'd like to suggest is:

  • postgres/serverless
  • postgres/tcp
  • neon/http
  • neon/ws
  • neon (as an alias to postgres/serverless)

I can expand the docs with clear reasons when to choose which of each options.

Auto-generating connection strings

How do you feel about leveraging import { instantPostgres } from 'get-db' to generate a connection string to people who choose one of the above connectors but did not pass a url? We do that only in dev (to avoid weirdness in CI and deploy), and extend the docs to make it clearer, something like

import { createDatabase } from "db0";
import postgresql from "db0/connectors/postgresql";

const db = createDatabase(
  postgresql({
    connectionString: process.env.DATABASE_URL, // if falsy, generate on the fly and push data.
    seedScript: "path/to/seed.sql", // if present, check if DB is empty and seed
    bindingName: "DB",
  }),
);

Thoughts?

@atilafassina atilafassina marked this pull request as ready for review November 13, 2025 11:51
@pi0 pi0 changed the title Add Neon integration for serverless Postgres feat: add neon for serverless postgres Nov 20, 2025
@pi0 pi0 changed the title feat: add neon for serverless postgres feat: add neon for serverless postgres Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants