Getting Started with Neon: A Practical Guide to Serverless PostgreSQL

Neon is a modern serverless PostgreSQL platform that separates compute from storage, offering instant branching, autoscaling, and a generous free tier. Unlike traditional databases, you only pay for the compute time you use, making it ideal for development, testing, and production workloads. In this tutorial, you’ll learn how to set up a Neon project and leverage its core features.

To start, sign up at neon.tech and log into the console. Click “New Project” and choose a name and region. Once created, you’ll see your connection string (postgres://…). This string is all you need to connect from any PostgreSQL client or framework like Prisma, Django, or Node.js. You can also create read replicas and non-primary branches from the dashboard.

Article illustration

Using Neon’s Branching for Development

One of Neon’s standout features is database branching. Create a branch from your main database in seconds – perfect for isolated testing environments. Each branch is a full copy-on-write clone. Use the “Branches” tab in the console to create a branch named “dev-feature”. You get a separate connection string. After changes, you can merge the branch back to the main (future feature) or simply delete it.

Connecting with Serverless and Pooling

Neon provides a built-in connection pooler via the same endpoint but with a different port (5432 for direct, 5433 for pooled). For serverless functions (AWS Lambda, Vercel), always use the pooled connection to avoid exhausting connections. In Node.js, use `@neondatabase/serverless` driver which handles WebSocket connections. Example: import { neon } from '@neondatabase/serverless'; const sql = neon(process.env.DATABASE_URL); await sql`SELECT 1`;. This driver is optimized for edge environments.

Autoscaling and Pricing

Neon automatically scales compute resources from 0 to 1 vCPU (free tier) or higher on paid plans. You are billed per second of active compute. Storage is billed separately. The free tier includes 500 MB of storage and 100 compute hours per month – enough for small projects.

Conclusion

Neon brings the convenience of serverless to PostgreSQL, making it easy to spin up databases, branch for development, and connect from modern serverless apps. Start with the free tier, experiment with branching, and you’ll see how it streamlines your data workflows.

sarah antaboga
Author: sarah antaboga

Leave a Reply

Your email address will not be published. Required fields are marked *