Socket
Book a DemoInstallSign in
Socket

@bknd/postgres

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bknd/postgres

This packages adds an adapter to use a Postgres database with [`bknd`](https://github.com/bknd-io/bknd). It works with both `pg` and `postgres` drivers, and supports custom postgres connections. * works with any Postgres database (tested with Supabase, Ne

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Postgres adapter for bknd (experimental)

This packages adds an adapter to use a Postgres database with bknd. It works with both pg and postgres drivers, and supports custom postgres connections.

  • works with any Postgres database (tested with Supabase, Neon, Xata, and RDS)
  • choose between pg and postgres drivers
  • create custom postgres connections with any kysely postgres dialect

Installation

Install the adapter with:

npm install @bknd/postgres

Using pg driver

Install the pg driver with:

npm install pg

Create a connection:

import { pg } from "@bknd/postgres";

// accepts `pg` configuration
const connection = pg({
   host: "localhost",
   port: 5432,
   user: "postgres",
   password: "postgres",
   database: "postgres",
});

// or with a connection string
const connection = pg({
   connectionString: "postgres://postgres:postgres@localhost:5432/postgres",
});

Using postgres driver

Install the postgres driver with:

npm install postgres

Create a connection:

import { postgresJs } from "@bknd/postgres";

// accepts `postgres` configuration
const connection = postgresJs("postgres://postgres:postgres@localhost:5432/postgres");

Using custom postgres dialects

You can create a custom kysely postgres dialect by using the createCustomPostgresConnection function.

import { createCustomPostgresConnection } from "@bknd/postgres";

const connection = createCustomPostgresConnection(MyDialect)({
   // your custom dialect configuration
   supports: {
      batching: true
   },
   excludeTables: ["my_table"],
   plugins: [new MyKyselyPlugin()],
});

Custom neon connection

import { createCustomPostgresConnection } from "@bknd/postgres";
import { NeonDialect } from "kysely-neon";

const connection = createCustomPostgresConnection(NeonDialect)({
   connectionString: process.env.NEON,
});

Custom xata connection

import { createCustomPostgresConnection } from "@bknd/postgres";
import { XataDialect } from "@xata.io/kysely";
import { buildClient } from "@xata.io/client";

const client = buildClient();
const xata = new client({
   databaseURL: process.env.XATA_URL,
   apiKey: process.env.XATA_API_KEY,
   branch: process.env.XATA_BRANCH,
});

const connection = createCustomPostgresConnection(XataDialect, {
   supports: {
      batching: false,
   },
})({ xata });

FAQs

Package last updated on 07 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.