skills/bun-guides-ecosystem-neon-serverless-postgres/SKILL.md
Use Neon's Serverless Postgres with Bun
npx skillsauth add jarle/bun-skills Bun Use Neon's Serverless Postgres with BunInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Neon is a fully managed serverless Postgres. Neon separates compute and storage to offer modern developer features such as autoscaling, branching, bottomless storage, and more.
Get started by creating a project directory, initializing the directory using bun init, and adding the Neon serverless driver as a project dependency.
mkdir bun-neon-postgres
cd bun-neon-postgres
bun init -y
bun add @neondatabase/serverless
Create a .env.local file and add your Neon Postgres connection string to it.
DATABASE_URL=postgresql://usertitle:[email protected]/neondb?sslmode=require
Paste the following code into your project's index.ts file.
import { neon } from "@neondatabase/serverless";
// Bun automatically loads the DATABASE_URL from .env.local
// Refer to: https://bun.com/docs/runtime/environment-variables for more information
const sql = neon(process.env.DATABASE_URL);
const rows = await sql`SELECT version()`;
console.log(rows[0].version);
Start the program using bun ./index.ts. The Postgres version should be printed to the console.
bun ./index.ts
PostgreSQL 16.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
This example used the Neon serverless driver's SQL-over-HTTP functionality. Neon's serverless driver also exposes Client and Pool constructors to enable sessions, interactive transactions, and node-postgres compatibility.
Refer to Neon's documentation for a complete overview of the serverless driver.
development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling