PostgreSQL: Set up Lucia Auth for local Postgres DB vs Vercel Postgres

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


I switched a codebase from local Postgres database to Vercel Postgres, which comes with its own optimized package.

I used this to connect Lucia Auth:

import { postgres as postgresAdapter } from '@lucia-auth/adapter-postgresql'
import postgres from 'postgres'

const POSTGRES_URL = //..lookup from env variables

const postgresDatabase = postgres(POSTGRES_URL)

const auth = lucia({
  adapter: postgresAdapter(
    postgresDatabase,
    dbConfig
  ),
	//...
})

With Vercel Postgres, I used:

import { pg } from '@lucia-auth/adapter-postgresql'
import { db } from '@vercel/postgres'

const auth = lucia({
  adapter: pg(db, dbConfig),
	//...
})

The db now already know how to look up the environment variable POSTGRES_URL

Lessons in this unit:

0: Introduction
1: Introduction to PostgreSQL
2: How to install PostgreSQL on macOS
3: How to create a PostgreSQL database
4: Navigating Databases in PostgreSQL
5: PostgreSQL User Permissions
6: Tables and Data Types
7: Where to host a PostgreSQL database
8: PostgreSQL vs MySQL
9: Troubleshooting PostgreSQL
10: Vercel Postgres, no transactions?
11: ▶︎ Set up Lucia Auth for local Postgres DB vs Vercel Postgres
12: Connect to Postgres local vs Vercel Postgres with Kysely