Click Connect in the Neon Console to open the Connect to your branch modal and copy the connection string (docs). Save it as an environment variable (usually DATABASE_URL) and pass it to a Postgres driver in your code. Lakebase Postgres speaks the standard Postgres wire protocol, so standard clients and ORMs work: pg, psycopg2, psql, Prisma, Drizzle, SQLAlchemy, and others. For serverless and edge runtimes, the Neon serverless driver connects over HTTP or WebSockets instead of TCP.
1. Save the connection string in.env
DATABASE_URL="postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=require"Add .env to .gitignore. Keep the sslmode=require and channel_binding=require parameters, because Lakebase Postgres requires TLS.
2. Connect from your code
// Best for serverless and edge runtimes
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL);
const rows = await sql`SELECT * FROM users WHERE id = ${1}`;
console.log(rows);For Prisma, Drizzle, SQLAlchemy, and other ORMs, see the framework guides.
3. Pick the right connection type
Each connection string comes in two forms:
- Pooled (hostname has
-pooler): routes through PgBouncer in transaction mode and accepts up to 10,000 client connections per compute. Use it for serverless functions, web apps, and other high-concurrency clients. - Direct: connects straight to Postgres. Use it for migrations,
pg_dump,LISTEN/NOTIFY, logical replication, and other session-level features. Themax_connectionslimit for direct connections depends on compute size, from 104 at 0.25 CU to 4,000 at 9 CU and above.
The Connection pooling toggle in the modal switches between them, and pooled is the default. A common setup is DATABASE_URL for the pooled string and a second variable, such as DIRECT_URL, for the direct string that migrations use. See Connection pooling for when to use which.
Always read the string from the environment
The connection string includes your password, so a URL hardcoded in source code ends up in your Git history. Read it from process.env.DATABASE_URL, os.environ, or your secret manager. If you deploy to Vercel, Render, Fly, or a similar host, set DATABASE_URL in its environment settings. The Vercel-Managed Integration sets it for you.

Compare drivers and connection types based on where you're deploying.








