Prerequisites
Before deploying, make sure you have:- A Vercel account
- An Upstash Redis database with credentials
- Your project code in a Git repository (GitHub, GitLab, or Bitbucket)
Deploy from Git
Import your repository
Go to vercel.com/new and click “Import Project”.If this is your first time, you’ll need to connect your Git provider (GitHub, GitLab, or Bitbucket).
Select your repository
Choose the repository containing your Private Chat project.
If you don’t see your repository, you may need to configure Vercel’s access to your Git provider.
Configure project
Vercel will auto-detect that this is a Next.js project. The default settings should work:
- Framework Preset: Next.js
- Root Directory:
./(or your source directory if different) - Build Command:
next build - Output Directory:
.next
Add environment variables
Click “Environment Variables” to expand the section.Add your Upstash Redis credentials:
Deploy
Click “Deploy” and wait for Vercel to build and deploy your application.This usually takes 1-3 minutes. You’ll see real-time build logs as your project is deployed.
Automatic deployments
Vercel automatically deploys your application when you push changes to your Git repository:- Production: Deployments from your main branch (usually
mainormaster) - Preview: Deployments from pull requests and other branches
Custom domain
To add a custom domain to your deployment:Configure DNS
Vercel will provide DNS records to add to your domain registrar:
- A Record: Points to Vercel’s IP address
- CNAME Record: For subdomains
Environment variables management
To update environment variables after deployment:Edit or add variables
You can:
- Add new variables
- Edit existing values
- Delete variables
- Set different values for Production, Preview, and Development
Environment variable changes are not applied to existing deployments automatically. You must redeploy for the changes to take effect.
Troubleshooting
Build fails
If your build fails:- Check the build logs in Vercel for error messages
- Ensure all environment variables are set correctly
- Verify your code builds locally with
npm run build - Check that all dependencies are listed in
package.json
Runtime errors
If your app builds but has runtime errors:- Check the Function Logs in your Vercel dashboard
- Verify your Upstash Redis credentials are correct
- Test your Redis connection locally
- Ensure your Upstash database region matches or is close to your Vercel deployment region
Real-time messaging not working
If real-time features aren’t working:- Verify
UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKENare set - Check that your Upstash database is active and not paused
- Review Function Logs for WebSocket connection errors
- Test the
/api/realtimeendpoint directly
Next steps
- Set up custom domains
- Configure preview deployments
- Monitor analytics and performance