Deploy to Netlify
This guide explains how to deploy ReResell to Netlify.
Prerequisites
- A Netlify account
- Your code pushed to GitHub
- A Neon PostgreSQL database
Step 1: Connect Repository
- Log in to Netlify
- Click "Add new site" → "Import an existing project"
- Select GitHub and authorize Netlify
- Choose the
recycle-resellrepository
Step 2: Configure Build Settings
Netlify should auto-detect Next.js. Verify these settings:
| Setting | Value |
|---|---|
| Base directory | (leave empty) |
| Build command | npm run build |
| Publish directory | .next |
Step 3: Add Environment Variables
Go to Site settings → Environment variables and add:
Required Variables
DATABASE_URL=postgresql://user:pass@host/db?sslmode=require
NEXTAUTH_SECRET=your-generated-secret
NEXTAUTH_URL=https://your-site.netlify.app
Optional Variables
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
BLOB_READ_WRITE_TOKEN=your-vercel-blob-token
PUSHER_APP_ID=your-pusher-app-id
PUSHER_KEY=your-pusher-key
PUSHER_SECRET=your-pusher-secret
PUSHER_CLUSTER=your-pusher-cluster
NEXT_PUBLIC_PUSHER_KEY=your-pusher-key
NEXT_PUBLIC_PUSHER_CLUSTER=your-pusher-cluster
Step 4: Deploy
- Click "Deploy site"
- Wait for the build to complete
- Your site will be available at
https://your-site.netlify.app
Step 5: Update NEXTAUTH_URL
After the first deploy:
- Copy your Netlify site URL
- Update the
NEXTAUTH_URLenvironment variable - Trigger a redeploy: Deploys → Trigger deploy
Custom Domain
To use a custom domain:
- Go to Domain management
- Click "Add custom domain"
- Follow the DNS configuration instructions
- Update
NEXTAUTH_URLto your custom domain
Troubleshooting
Build Fails
Check the deploy logs for errors. Common issues:
- Missing environment variables
- TypeScript errors
- Dependency issues
Database Connection Issues
Ensure your Neon database:
- Is accessible from Netlify's IP addresses
- Has the correct SSL mode (
sslmode=require) - Credentials are correct
Authentication Not Working
Verify:
NEXTAUTH_URLmatches your deployed URL exactlyNEXTAUTH_SECRETis set- Google OAuth redirect URIs include your Netlify URL
Auto-Deploy
By default, Netlify auto-deploys when you push to the main branch. You can:
- Lock deploys to prevent auto-deploy
- Set up deploy previews for pull requests
- Configure deploy notifications