NEON

Very similar to Postgres connector, but optimized for serverless environments.

Read more in neon.com.

#Why Neon Connector?

The fundamental difference is that Postgres Connector uses the node-postgres driver, which needs a raw TCP connection, while Neon uses neondatabase/serverless, whose Client speaks postgres over WebSockets. The drivers have feature parity, but the connection type creates some runtime differences.

A WebSocket connection is usually preferred over TCP for serverless environments because many of those runtimes cannot open raw TCP sockets at all.

#Usage

Install the Neon Serverless Driver for the postgres connection.

npm i @neondatabase/serverless

This connector always connects to an existing database, so a connection string is required.

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

const db = createDatabase(
  neon({
    url: process.env.DATABASE_URL,
  }),
);
Read more in Query parameters.

#Options

Options are passed through to the underlying Client, so any ClientConfig field is accepted in addition to the following.

#url or connectionString

  • Type: string
  • Connection string to your Neon database.
  • Optional if the database is identified another way, such as a host in the ClientConfig. If neither is present, the first query throws (the client connects lazily).

db0  tiny sql connector.