@porulle/adapter-neon
v0.20.2
Published
Workers-grade Neon DatabaseAdapter for @porulle/core: Neon HTTP queries with request-scoped Neon or Hyperdrive transactions.
Readme
@porulle/adapter-neon
Workers-grade Neon DatabaseAdapter for @porulle/core.
Two transports, picked by query type — the design proven in production by porulle's first adopter (a live iPad POS on Cloudflare Workers + Neon):
- Plain queries go through
@neondatabase/serverlessHTTP — stateless, no socket-reuse races across Workers isolates. transaction()creates a fresh client per call and closes it before the request completes. Direct Neon connections use a WebSocketPool; Hyperdrive connections use Postgres.js over Workers TCP. This distinction is required because Neon WebSocket clients cannot speak to Hyperdrive's TCP endpoint.drizzle-orm/neon-httpcannot run interactive transactions.
Usage
import { defineConfig } from "@porulle/core";
import { neonAdapter } from "@porulle/adapter-neon";
export default defineConfig({
databaseAdapter: neonAdapter({
connectionString: env.DATABASE_URL, // direct Neon URL
// Optional: route transactions through Hyperdrive using Postgres.js
hyperdrive: env.HYPERDRIVE,
}),
// ...
});connectionString— direct Neon URL (postgresql://...neon.tech/...). Used by the HTTP driver, and by transaction pools when no Hyperdrive binding is given.hyperdrive— optional Cloudflare Hyperdrive binding (any object exposingconnectionString). When set, transactions use a fresh Postgres.js client over Hyperdrive; plain queries keep using Neon HTTP againstconnectionString.
.execute() results are normalized to the postgres-js shape (an array of
rows), matching what @porulle/core and custom routes expect.
