vercel deployment - nself-org/nchat GitHub Wiki
Version: 1.0.0 Last Updated: 2026-01-31 Difficulty: Beginner-Friendly Estimated Time: 15-30 minutes
This guide provides step-by-step instructions for deploying nchat to Vercel with one-click deployment support.
- Why Vercel?
- Prerequisites
- Quick Start: One-Click Deploy
- Manual Deployment
- Environment Variables Setup
- Backend Configuration
- Custom Domain Setup
- Deployment Status & Monitoring
- Troubleshooting
- Advanced Configuration
Vercel is the ideal platform for deploying nchat because:
- Zero Configuration: Works out-of-the-box with Next.js 15
- Global CDN: Automatic edge caching and fast page loads
- Automatic SSL: Free HTTPS certificates for all deployments
- Preview Deployments: Every git push gets a preview URL
- Serverless Functions: Built-in API route support
- Free Tier: Generous free tier for hobby projects
- Easy Rollbacks: One-click rollback to previous deployments
Before deploying, ensure you have:
- GitHub Account - For connecting your repository
- Vercel Account - Sign up free
- Backend Services - Running nself backend OR Nhost cloud account
- Environment Variables - Listed below
Note: If you don't have a backend yet, you can deploy the frontend first and connect it later.
-
Fork the Repository
- Visit https://github.com/yourusername/nself-chat
- Click "Fork" in the top-right corner
-
Deploy to Vercel
Click the button below to deploy:
-
Configure Environment Variables (see Environment Variables Setup)
-
Deploy!
- Click "Deploy"
- Wait 2-3 minutes for build to complete
- Visit your new deployment URL
-
Login to Vercel
- Go to vercel.com
- Sign in with GitHub
-
Import Project
- Click "Add New..." → "Project"
- Select your forked
nself-chatrepository - Click "Import"
-
Configure Project
- Framework Preset: Next.js (auto-detected)
-
Root Directory:
./(default) -
Build Command:
pnpm build(auto-detected) -
Output Directory:
.next(auto-detected)
-
Add Environment Variables (see next section)
-
Deploy!
-
Install Vercel CLI
pnpm install -g vercel
-
Login to Vercel
vercel login
-
Deploy from Project Directory
cd /path/to/nself-chat vercel -
Follow the prompts:
- Set up and deploy? Y
- Which scope? Select your account
- Link to existing project? N (first time)
- Project name? nchat (or your preference)
- Directory? ./ (current directory)
- Override settings? N (use defaults)
-
Deploy to Production
vercel --prod
These variables must be set for nchat to work:
| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_USE_DEV_AUTH |
Enable dev auth (set to false for production) |
false |
NEXT_PUBLIC_APP_NAME |
Your app name | nchat |
NEXT_PUBLIC_APP_URL |
Your deployment URL | https://nchat.vercel.app |
NEXT_PUBLIC_GRAPHQL_URL |
Hasura GraphQL endpoint | https://api.yourproject.nhost.run/v1/graphql |
NEXT_PUBLIC_AUTH_URL |
Authentication service URL | https://auth.yourproject.nhost.run/v1/auth |
NEXT_PUBLIC_STORAGE_URL |
File storage URL | https://storage.yourproject.nhost.run/v1/storage |
- Go to your project in Vercel
- Click "Settings" → "Environment Variables"
- Add each variable:
-
Name: Variable name (e.g.,
NEXT_PUBLIC_APP_NAME) -
Value: Variable value (e.g.,
nchat) - Environment: Select "Production", "Preview", and "Development"
-
Name: Variable name (e.g.,
- Click "Save"
# Add single variable
vercel env add NEXT_PUBLIC_APP_NAME production
# Add from .env file
vercel env pull .env.productionFor enhanced features, add these optional variables:
# Sentry Error Tracking
NEXT_PUBLIC_SENTRY_DSN=https://[key]@[org].ingest.sentry.io/[project]
SENTRY_ORG=your-org
SENTRY_PROJECT=your-project
SENTRY_AUTH_TOKEN=your-auth-token
# Analytics
NEXT_PUBLIC_GA_ID=G-XXXXXXXXXX
# Social Authentication
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
# Email Service
SENDGRID_API_KEY=your-sendgrid-keynchat requires a backend for full functionality. You have two options:
-
Sign up for Nhost
- Visit nhost.io
- Create a free account
- Create a new project
-
Get Your URLs
- Go to project "Settings" → "Overview"
- Copy these URLs:
- GraphQL URL
- Auth URL
- Storage URL
-
Add to Vercel
- Add the URLs as environment variables in Vercel
- Redeploy your project
-
Deploy nself Backend
See nself CLI Documentation for deployment options:
- Docker Compose
- Kubernetes
- Traditional server
-
Configure Public URLs
Ensure your backend services are accessible via HTTPS:
-
https://api.yourdomain.com→ Hasura -
https://auth.yourdomain.com→ Auth service -
https://storage.yourdomain.com→ Storage service
-
-
Update Environment Variables
Point your Vercel deployment to your backend URLs.
For testing without a backend:
NEXT_PUBLIC_USE_DEV_AUTH=trueThis enables 8 test users with auto-login. DO NOT use in production!
-
Go to Vercel Dashboard
- Select your project
- Click "Settings" → "Domains"
-
Add Domain
- Enter your domain (e.g.,
chat.yourdomain.com) - Click "Add"
- Enter your domain (e.g.,
-
Configure DNS
Vercel will show you DNS records to add:
For subdomain (chat.yourdomain.com):
Type: CNAME Name: chat Value: cname.vercel-dns.comFor root domain (yourdomain.com):
Type: A Name: @ Value: 76.76.21.21 -
Wait for Verification
- DNS propagation takes 5-60 minutes
- Vercel automatically provisions SSL certificate
- Domain status will change to "Valid"
-
Update Environment Variable
Update
NEXT_PUBLIC_APP_URLto your custom domain:NEXT_PUBLIC_APP_URL=https://chat.yourdomain.com
-
Vercel Dashboard
- Go to vercel.com/dashboard
- Click your project
- See recent deployments with status
-
Deployment Logs
- Click any deployment
- View build logs and runtime logs
- Check for errors or warnings
nchat includes a built-in deployment status checker in the admin panel:
- Login as admin
- Go to "Settings" → "Deployment"
- View:
- Current deployment status
- Build information
- Environment health checks
- SSL certificate status
For production error tracking:
- Sign up at sentry.io
- Create a new Next.js project
- Copy your DSN
- Add to Vercel environment variables:
NEXT_PUBLIC_SENTRY_DSN=https://[key]@[org].ingest.sentry.io/[project]
Problem: Vercel doesn't recognize pnpm
Solution: Add package.json field:
{
"packageManager": "[email protected]"
}Or create pnpm-lock.yaml in root directory.
Problem: Backend URLs are not set or incorrect
Solution:
- Check environment variables in Vercel
- Ensure URLs are HTTPS (not HTTP)
- Test URLs in browser/Postman
- Redeploy after fixing
Problem: NEXT_PUBLIC_USE_DEV_AUTH is true in production
Solution:
- Set
NEXT_PUBLIC_USE_DEV_AUTH=false - Ensure
NEXT_PUBLIC_AUTH_URLis correct - Redeploy
Problem: Storage URL is incorrect or CORS not configured
Solution:
- Verify
NEXT_PUBLIC_STORAGE_URL - Configure CORS in your storage service:
{ "allowed_origins": ["https://your-domain.vercel.app"], "allowed_methods": ["GET", "POST", "PUT", "DELETE"], "allowed_headers": ["*"] }
Problem: API routes take too long (10s free tier, 60s Pro)
Solution:
- Optimize database queries
- Add indexes to frequently queried fields
- Implement caching (Redis/Vercel KV)
- Upgrade to Pro plan for 60s timeout
Problem: Changed env vars but app still uses old values
Solution:
- Redeploy after changing env vars
- Clear Vercel cache:
vercel --force - Check variable scope (Production/Preview/Development)
Problem: Dynamic routes not working
Solution:
- Ensure
next.config.jsdoesn't override routes - Check file names in
src/app/match URL structure - Clear
.nextcache and rebuild
Problem: WebSocket connections fail
Solution:
- Vercel doesn't support WebSockets on edge
- Use Hasura Cloud or separate WebSocket server
- Configure WebSocket URL separately:
NEXT_PUBLIC_WS_URL=wss://your-hasura.nhost.run/v1/graphql
Problem: Build warns about large bundle size
Solution:
- Enable bundle analysis:
ANALYZE=true pnpm build
- Optimize imports (import only what you need)
- Enable code splitting
- Lazy load heavy components
Problem: Too many requests/bandwidth
Solution:
- Implement caching with
Cache-Controlheaders - Use Vercel Edge Config for static data
- Upgrade to Pro plan for higher limits
If you're still stuck:
-
Check Vercel Logs
- Deployment logs
- Runtime logs
- Error tracking
-
Community Support
-
Professional Support
- Vercel Support (Pro plan)
- nself Support
Create/edit vercel.json:
{
"version": 2,
"framework": "nextjs",
"buildCommand": "pnpm build",
"installCommand": "pnpm install",
"outputDirectory": ".next",
"regions": ["iad1"],
"env": {
"NODE_ENV": "production"
},
"headers": [
{
"source": "/api/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "s-maxage=1, stale-while-revalidate"
}
]
}
],
"redirects": [
{
"source": "/home",
"destination": "/chat",
"permanent": true
}
],
"rewrites": [
{
"source": "/api/graphql",
"destination": "https://api.yourproject.nhost.run/v1/graphql"
}
]
}For faster API routes, use Edge Runtime:
// src/app/api/config/route.ts
export const runtime = 'edge'
export async function GET(request: Request) {
// Your API logic
}Every git push to a branch creates a preview deployment:
-
Push to any branch:
git checkout -b feature/new-feature git push origin feature/new-feature
-
Vercel automatically deploys
-
Get unique preview URL
-
Share with team for testing
-
Merge to main for production deployment
Enable deployment protection:
- Go to "Settings" → "Deployment Protection"
- Enable options:
- Password Protection: Require password to access
- Vercel Authentication: Only team members can access
- Trusted IPs: Allow specific IP addresses
-
Enable Image Optimization
// next.config.js module.exports = { images: { domains: ['storage.yourproject.nhost.run'], formats: ['image/avif', 'image/webp'], }, }
-
Enable Compression
// vercel.json { "headers": [ { "source": "/(.*)", "headers": [ { "key": "Content-Encoding", "value": "gzip" } ] } ] }
-
Use Vercel Edge Config
import { get } from '@vercel/edge-config' const config = await get('app-config')
Before going live, verify:
- Environment Variables: All required vars set
- Dev Auth Disabled:
NEXT_PUBLIC_USE_DEV_AUTH=false - Backend Connected: GraphQL/Auth/Storage URLs working
- Custom Domain: DNS configured and SSL active
- Error Tracking: Sentry configured
- Analytics: Google Analytics or similar enabled
- Testing: Preview deployment tested thoroughly
- Performance: Lighthouse score > 90
- Security: Secrets not exposed in client-side code
- Monitoring: Uptime monitoring configured
- Backups: Database backups enabled
- Documentation: Updated with deployment URLs
| Tier | Price | Limits |
|---|---|---|
| Hobby | Free | 100 GB bandwidth, 1000 serverless functions |
| Pro | $20/month | 1 TB bandwidth, 1M serverless functions |
| Enterprise | Custom | Unlimited, SLA, custom support |
| Option | Price | Notes |
|---|---|---|
| Nhost Free | Free | 1 GB database, 1 GB storage |
| Nhost Starter | $25/month | 8 GB database, 20 GB storage |
| Self-hosted | $5-50/month | VPS costs (DigitalOcean, AWS, etc.) |
Total Estimated Cost for Small Team: $0-45/month
After successful deployment:
- Configure Setup Wizard - Run the 9-step setup wizard
- Create Channels - Set up your team channels
- Invite Users - Send invitation links
- Customize Branding - Update logo, colors, theme
- Enable Features - Turn on features you need
- Monitor Performance - Check Vercel analytics and Sentry