Database Setup with Neon
How to create a Neon Postgres project and connect it to BloggFast.
Last updated:
What is Neon?
Neon is a serverless Postgres platform that scales to zero when not in use, making it cost-effective for new or low-traffic projects. BloggFast uses Neon for two things:
- Primary database — stores articles, categories, authors, tags, users, subscribers, analytics, AI settings, and audit logs via Prisma 7
- Authentication — via Neon Auth, which provides cookie-based session management integrated with your Neon project
BloggFast uses the @prisma/adapter-neon driver adapter with @neondatabase/serverless for WebSocket-based connections, which is required for serverless environments like Vercel Edge Functions.
Create a Neon project
- Sign up at neon.tech
- Click New Project
- Name it (e.g.,
my-blog), choose a region close to your users, and select Postgres 16 - Click Create Project
Neon will provision a new Postgres instance and show you the connection details.
Connection strings (pooled vs direct)
Neon provides two types of connection strings — both are needed:
| Type | Variable | When to use |
|---|---|---|
| Pooled (with pgBouncer) | DATABASE_URL | Runtime queries in production and development — efficient connection pooling for serverless |
| Direct (no pgBouncer) | DATABASE_URL_UNPOOLED | Prisma migrations, seeding, and Prisma Studio — requires a persistent connection |
From your Neon dashboard → Connection Details, copy both strings:
# Pooled (hostname contains -pooler)
DATABASE_URL=postgresql://user:pass@ep-xxx-pooler.region.aws.neon.tech/neondb?channel_binding=require&sslmode=require
# Direct (no -pooler in hostname)
DATABASE_URL_UNPOOLED=postgresql://user:pass@ep-xxx.region.aws.neon.tech/neondb?sslmode=requireWarning
migrate dev. Always use DATABASE_URL_UNPOOLEDfor migrations.Run Prisma migrations
With your connection strings configured, apply the schema to your Neon database:
npm run db:migrate
# This runs: prisma migrate devThis creates all database tables defined in prisma/schema.prisma. You'll see output confirming each migration was applied. The schema includes 17 models covering everything from articles to email subscribers.
Alternatively, for a quick schema push without migration history:
npm run db:push
# This runs: prisma db pushTip
npm run db:generate (runs prisma generate). This is done automatically during npm run build.Seed the database
BloggFast includes a comprehensive seed script that creates starter categories, authors, AI settings, and site settings:
npm run db:seed
# This runs: npx tsx prisma/seed.tsRun this after your initial migration. It's safe to re-run — the seed script uses upsert operations to avoid duplicates.