@latimer-woods-tech/neon
Thin wrapper around@neondatabase/serverless scoped to Cloudflare’s Hyperdrive binding. Depends on @latimer-woods-tech/errors and @latimer-woods-tech/logger.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Neon Postgres client via Cloudflare Hyperdrive with connection retry.
@neondatabase/serverless scoped to Cloudflare’s Hyperdrive binding. Depends on @latimer-woods-tech/errors and @latimer-woods-tech/logger.
npm install @latimer-woods-tech/neon
// wrangler.jsonc
{
"hyperdrive": [{ "binding": "DB", "id": "<hyperdrive-id>" }]
}
createDb(binding)function createDb(binding: Hyperdrive): Db;
interface Db {
execute<T = Record<string, unknown>>(
sql: string,
params?: unknown[],
): Promise<{ rows: T[] }>;
}
withDbRetry(fn, opts?)function withDbRetry<T>(
fn: () => Promise<T>,
opts?: { retries?: number; delayMs?: number },
): Promise<T>;
DbErrorclass DbError extends FactoryError {
readonly query?: string;
}
import { createDb, withDbRetry } from '@latimer-woods-tech/neon';
const db = createDb(env.DB);
const result = await withDbRetry(() =>
db.execute<{ id: string; email: string }>(
'SELECT id, email FROM users WHERE id = $1',
[userId],
)
);
const user = result.rows[0];