Database Integration
With Nexty's automated database adaptation, you only need to configure one environment variable DATABASE_URL
, and the boilerplate will automatically select the optimal connection parameters based on the runtime platform (Vercel/Netlify/Server) and database provider (Supabase/Neon/self-hosted).
- Only required environment variable:
DATABASE_URL
- Built-in tools: Drizzle ORM + drizzle-kit (migration/push/studio) with seed data scripts
- Automatic optimization:
- Serverless (Vercel/Netlify/Lambda) automatically reduces to single connection to avoid limits
- Supabase/Neon automatically enables SSL
- Neon + Vercel automatically disables prepared statements to avoid compatibility issues
Using Supabase
Create Database
Visit the Supabase website and register an account. If you want to register with a custom domain email, complete Resend Integration and Domain Email Configuration first.
Click New Project
to create a new project

Remember the password you enter in this step

Assign the environment variable to the .env
or .env.local
file


Replace [YOUR-PASSWORD]
with the password you entered in the previous step.
Initialize Database
Initialize the database and seed data with commands:
# Initialize database
npm run db:migrate
# Import example pricing plan seed data
npm run db:seed
After completion, you will see the complete data tables in Supabase.

Using Neon
Create Database
Visit the Neon website and register an account. If you want to register with a custom domain email, complete Resend Integration and Domain Email Configuration first.
Click Create Project
to create a new project


Assign the environment variable to the .env
or .env.local
file


Initialize Database
Initialize the database and seed data with commands:
# Initialize database
npm run db:migrate
# Import example pricing plan seed data
npm run db:seed
After completion, you will see the complete data tables in Supabase.

Updating Database Schema
The package.json
provides some commonly used database operation commands.
When developing new features, if you need to create new tables or extend existing tables, follow these steps:
- Update database schema in
lib/db/schema.ts
- Run
npm run db:generate
command to automatically generate migration files - Run
npm run db:migrate
command to apply migration files to the database
If you use self-hosted Postgres, you can run npm run db:studio
to open the visualization interface.
Among the commands provided in package.json
, there's also "db:push": "drizzle-kit push"
. When you run npm run db:push
, it won't generate migration files but will update the database directly. This is not a standard practice and is generally not recommended.
Custom Drizzle Configuration
Nexty boilerplate has the capability to automatically create Drizzle configuration based on the deploying platform and database provider. The auto-configuration file is located at lib/db/config.ts
. The runtime environment supports detection of Vercel, Netlify, Lambda, and server environments. Database providers support Supabase, Neon, AWS RDS, GCP SQL, and self-hosted Postgres.
If your runtime environment or database provider is not among them, you can easily extend it in lib/db/config.ts
.
If deploying the project on a server, you can change the maximum connection count max
value based on your server's CPU and memory. If self-hosting Postgres or having specific compliance requirements, you can also override parameters.