General
Deployment
Learn how to deploy your Pro Next.js Drizzle application to production.
We recommend deploying your application to Vercel for the best experience, but you can deploy to any provider that supports Next.js and PostgreSQL.
Prerequisites
Before deploying, ensure you have:
- A GitHub repository with your project code.
- A PostgreSQL database (Neon, Supabase, Railway, etc.).
- A Stripe account (if using billing).
- A Resend account (if using email).
Deploying to Vercel
- Push your code to a GitHub repository.
- Import the project into Vercel.
- Add the required environment variables.
Environment Variables
At a minimum, you must set these variables for a production deployment:
Vercel Settings
BETTER_AUTH_SECRET="your-secret"
DATABASE_URL="postgresql://user:pass@host:5432/db?sslmode=require"
NEXT_PUBLIC_SITE_URL="https://your-app.com"Database Migrations
For Drizzle projects, migrations are typically run separately from the build process. You can:
- Run migrations manually after deployment using
npm run db:migrate - Use Vercel's post-deploy hook to run migrations automatically
- Include migrations in the build by modifying your build command (not recommended for production)
For production, it's recommended to run migrations as a separate step after deployment to avoid build failures affecting your deployment.
SSL and Database Connections
Most production database providers (like Neon or Supabase) require SSL. Ensure your DATABASE_URL includes ?sslmode=require.
.env
DATABASE_URL="postgresql://user:pass@ep-xxx.region.aws.neon.tech/neondb?sslmode=require"Post-Deployment Checklist
- Verify your custom domain is correctly configured with SSL.
- Configure your Stripe production webhooks to point to
https://your-domain.com/api/webhooks/stripe. - Update your OAuth redirect URIs in the Google Cloud Console or other provider dashboards.
- Ensure
NEXT_PUBLIC_SITE_URLmatches your production domain.