Overview
Neon is a serverless PostgreSQL database that works seamlessly with Drizzle ORM. It's the default database provider in the scaffold, offering automatic scaling, branching, and zero-downtime migrations.
Create Project
- Go to neon.tech and sign up for an account
- Click "Create Project"
- Choose a project name and region (select closest to your users)
- Select PostgreSQL version (15 or 16 recommended)
- Click "Create Project"
- Wait for the database to be provisioned (usually takes ~30 seconds)
Get Connection String
- In your Neon project dashboard, you'll see a connection string displayed
- Click "Copy" next to the connection string
- The connection string looks like:
postgresql://user:password@ep-xxx-xxx.region.aws.neon.tech/dbname?sslmode=require - Important: This is your database password - store it securely. You can also reset it in "Settings" → "Password" if needed
Connection Pooling (Optional but Recommended): Neon also provides a pooled connection string for better performance with serverless functions. Look for the "Pooled connection" option in the dashboard.
Environment Variables
Add this variable to your .env.local file:
# Neon Postgres DATABASE_URL="postgresql://user:password@ep-xxx-xxx.region.aws.neon.tech/dbname?sslmode=require"
Important:
- Replace the connection string with your actual Neon connection string
- For production, use environment variables in your hosting platform (Vercel, etc.)
- Never commit
.env.localto git (it's already in.gitignore)
Run Migrations
After setting DATABASE_URL, run the database migrations:
# Generate migrations from your schema npx drizzle-kit generate # Push migrations to your database npx drizzle-kit push
This will create all the required tables (users, sessions, accounts, subscriptions, etc.) in your Neon database.
Alternative: Use Drizzle Studio (Optional) View and manage your database with Drizzle Studio:
npx drizzle-kit studio
This opens a local web interface to browse your database tables and data.
Testing
- Restart your dev server:
npm run dev - Navigate to
http://localhost:3000/sign-up - Create a test account
- Verify the user was created in your database (use Drizzle Studio or Neon dashboard)
- Sign in and verify sessions work correctly
Using Neon Dashboard:
- Go to your Neon project dashboard
- Click "SQL Editor"
- Run:
SELECT * FROM user;to see created users
Troubleshooting:
- If connection fails, verify the connection string is correct
- Check that SSL mode is set to
requirein the connection string - Ensure your IP isn't blocked (Neon allows all IPs by default)
- For serverless environments (Vercel), connection pooling is recommended