DEV Community

Arhan Khan
Arhan Khan

Posted on

Neon for Beginners: Serverless Postgres That Scales to Zero

Neon is serverless Postgres. It gives you a full PostgreSQL database that scales to zero when nobody is using it, so you stop paying for idle time. If you like Postgres but hate paying for a database server that sits idle overnight, Neon is built for that frustration.

How does it work? Neon separates storage from compute. Your data lives in cloud storage, and a compute unit spins up when a connection arrives and scales down when it is not needed. You connect with a normal Postgres connection string, so every Postgres tool and library you already know keeps working.

# Connect with psql using the connection string from the Neon console
psql "postgresql://user:password@ep-xxx.us-east-2.aws.neon.tech/neondb?sslmode=require"
Enter fullscreen mode Exit fullscreen mode
-- It is just Postgres — nothing new to learn
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT UNIQUE NOT NULL,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

INSERT INTO users (name, email) VALUES ('Arhan', 'arhan@example.com');
SELECT * FROM users;
Enter fullscreen mode Exit fullscreen mode
// Use it from Node.js with any Postgres client
import { neon } from '@neondatabase/serverless';

const sql = neon(process.env.DATABASE_URL);
const users = await sql`SELECT * FROM users`;
console.log(users);
Enter fullscreen mode Exit fullscreen mode

Neon is great for beginners because you get real Postgres — not a simplified version — with a generous free tier. The branching feature is also a quiet superpower: you can create a copy of your database in seconds, test a risky migration on it, and throw it away.

When should you use Neon? For any app that needs Postgres, from a side project to a production app, especially when your traffic is uneven. It is a natural fit for apps hosted on Vercel, where connections come and go constantly.

The limits are worth knowing. Cold starts exist: the first request after a period of inactivity can take a few seconds while compute spins up. And Neon is Postgres in the cloud, so you still need to learn SQL and think about indexes — the database does not do that thinking for you.

Start today: create a free Neon project, connect with psql, and make a table with one row. If you can do that, you can run any Postgres app.

Top comments (0)