Skip to main content
General
Deployment

Render

Learn how to deploy your application to Render.

Open MarkdownFull AI corpusFeedback

Render is a managed cloud platform for deploying web services and PostgreSQL databases from a Git repository.

Why Render?

  • Git-based deployment - Build automatically from your production branch
  • Managed HTTPS - Connect a custom domain with managed TLS
  • Database support - Provision PostgreSQL or connect an external database
  • Release controls - Run migrations with a pre-deploy command on supported plans

Deploying to Render

1. Create Render Account

Sign up for a free account at render.com.

2. Create New Web Service

  1. Click "New +" in the Render dashboard
  2. Select "Web Service"
  3. Choose "Build and deploy from a Git repository"
  4. Connect your GitHub account if prompted
  5. Select your repository

3. Configure Service

Set the following configuration:

  • Name: Your application name
  • Region: Choose closest to your users
  • Branch: main or your production branch
  • Root Directory: / (leave empty if root)
  • Runtime: Node
  • Build Command: npm run build
  • Start Command: npm start

4. Add Environment Variables

Add the deployment variables. DATABASE_URL and BETTER_AUTH_SECRET are required. Add the Stripe and Resend variables when those features are enabled:

  1. Scroll to "Environment Variables" section
  2. Add variables from your .env:
Render Environment Variables
DATABASE_URL=postgresql://...
BETTER_AUTH_SECRET=...
NEXT_PUBLIC_SITE_URL=https://your-app.onrender.com
STRIPE_SECRET_KEY=...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=...
STRIPE_WEBHOOK_SECRET=...
NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_PRO_YEARLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_LIFETIME=price_...
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_STARTER=price_...
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASIC=price_...
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_PRO=price_...
RESEND_API_KEY=...
EMAIL_FROM=...

5. Select Plan

Choose a plan that supports the uptime, compute and deployment features your application needs. A testing plan can be suitable for evaluation, but use an always-on service for production and confirm that your selected plan supports the pre-deploy migration command described below.

6. Deploy

Click "Create Web Service" and Render will:

  • Install dependencies
  • Build your application
  • Deploy to their infrastructure

Your app will be available at https://your-app.onrender.com.

Database Migrations

Keep the build command as npm run build. On a paid Render service, set the Pre-Deploy Command to:

Render Pre-Deploy Command
npm run db:migrate

Render runs this after a successful build and before the new revision goes live. If your plan does not support pre-deploy commands, run the same command once from a trusted release environment against the production DATABASE_URL before deploying the application revision.

Do not use npm run db:push in production and do not run migrations from every web-service replica at startup.

Provision Database (Optional)

Render can provision a PostgreSQL database:

  1. Click "New +""PostgreSQL"
  2. Configure database settings
  3. Render will automatically set DATABASE_URL
  4. Link the database to your web service

Custom Domain

To use a custom domain:

  1. Go to SettingsCustom Domains
  2. Add your domain
  3. Follow DNS configuration instructions
  4. Update NEXT_PUBLIC_SITE_URL to your custom domain

Auto-Deploy

Render automatically deploys when you push to your connected branch. You can:

  • Enable/disable auto-deploy in settings
  • Set up manual deploys
  • Configure deploy hooks

Monitoring

Render provides:

  • Logs - Real-time application logs
  • Metrics - CPU, memory usage
  • Events - Deployment history

Troubleshooting

Service Sleeping (Free Tier)

The free tier service sleeps after 15 minutes of inactivity. To prevent this:

  • Upgrade to a paid plan
  • Use a service like UptimeRobot to ping your app

Build Failures

  • Check build logs in the Render dashboard
  • Verify Node.js 22.21.1 is selected, matching the version in package.json
  • Ensure all dependencies are in package.json

Database Connection Issues

  • Verify DATABASE_URL is set correctly
  • Check if database requires SSL (add ?sslmode=require)
  • Ensure database and web service are in the same region

Environment Variables

  • Verify variables are set correctly
  • Redeploy after adding new variables
  • Check for typos in variable names