Overview
RLink is optimized for deployment on Vercel, with built-in support for:- Automatic deployments from Git
- Environment variable management
- Serverless functions for API routes
- Cron jobs for scheduled tasks
- Edge network for global performance
Prerequisites
Vercel Account
Vercel Account
Sign up for a free account at vercel.com
Neon Database
Neon Database
Create a PostgreSQL database at neon.tech
- Note your connection string
- Ensure database is accessible from Vercel
Resend Account
Resend Account
Create an account at resend.com
- Get your API key
- Verify your sending domain
Git Repository
Git Repository
Ensure your code is pushed to GitHub, GitLab, or Bitbucket
Deployment Steps
1. Connect Repository to Vercel
Import Project
- Go to Vercel Dashboard
- Click “Add New…” → “Project”
- Select your Git provider (GitHub)
- Import the
rlinkrepository
Configure Build Settings
Vercel auto-detects Next.js:
- Framework Preset: Next.js
- Build Command:
next build - Output Directory:
.next - Install Command:
npm install
No changes needed - Vercel uses these defaults automatically
2. Configure Environment Variables
In your Vercel project settings, add all environment variables:Database Configuration
Database Configuration
Application URLs
Application URLs
your-domain with your actual Vercel domainCORS & Security
CORS & Security
Email Configuration
Email Configuration
Authentication Secrets
Authentication Secrets
Cron & Cache Secrets
Cron & Cache Secrets
3. Deploy Database Schema
Before your first deployment, apply database migrations:Alternatively, you can run migrations from Vercel by adding a custom build script, but local migration is recommended for first deployment.
4. Configure Cron Jobs
RLink uses Vercel Cron for scheduled tasks.Verify vercel.json
Ensure This runs daily at midnight UTC to clean up old activity logs.
vercel.json exists in your project root:Set Cron Secret
In Vercel dashboard:
- Go to Settings → Environment Variables
- Ensure
CRON_SECRETis set - Vercel will automatically add this as
Authorization: Bearer {CRON_SECRET}header
5. Deploy Application
Trigger Deployment
Click “Deploy” in Vercel dashboard, or push to your main branch to trigger automatic deployment.
Monitor Build
Watch the build logs in Vercel dashboard. Common issues:
- Environment variable typos
- Database connection errors
- Missing dependencies
Post-Deployment Checklist
Custom Domain Setup
1. Add Domain to Vercel
Add Domain
- Go to Project Settings → Domains
- Click “Add Domain”
- Enter your domain (e.g.,
rlink.rlanddevelopment.com)
Configure DNS
Add the following DNS records at your domain registrar:A Record:AAAA Record (for IPv6):Or use CNAME for subdomains:
Environment-Specific Configuration
Production Environment
Staging Environment
For a staging deployment:Create a separate Vercel project for staging linked to a
staging or develop branch.Continuous Deployment
Automatic Deployments
Vercel automatically deploys when you push to connected branches:- Production: Pushes to
main→ Production deployment - Preview: Pushes to other branches → Preview deployment
Branch Protection
Configure branch protection in GitHub:Performance Optimization
1. Enable Edge Functions
For routes that benefit from running at the edge, you can opt in explicitly (validate compatibility with your dependencies first):2. Configure Caching
Set proper cache headers innext.config.ts:
3. Optimize Images
Images are automatically optimized by Next.js Image component. Ensure you’re using it:Monitoring & Logging
Vercel Analytics
Enable Vercel Analytics for production insights:- Go to Project Settings → Analytics
- Enable Web Analytics
- View metrics in dashboard
Error Tracking
Consider integrating error tracking for production:- Sentry: For comprehensive error monitoring
- LogRocket: For session replay
- Vercel Logs: Built-in log streaming
Rollback Strategy
If a deployment causes issues:Instant Rollback
In Vercel dashboard:
- Go to Deployments
- Find last working deployment
- Click ”…” → “Promote to Production”
Security Hardening
Security Headers
Security Headers
Verify security headers are set in
next.config.ts:Rate limiting
Rate limiting
Apply rate limits at the application or edge layer for sensitive routes (login, public APIs). Tune limits for legitimate traffic spikes.
Database Security
Database Security
- Enable SSL mode in connection string (
?sslmode=require) - Use Neon’s IP allowlist if needed
- Rotate database passwords regularly
Secret Rotation
Secret Rotation
Rotate secrets periodically:
- Generate new secret
- Update in Vercel environment variables
- Redeploy application
- Invalidate old sessions (users will need to re-login)
Troubleshooting
Database Connection Errors
Database Connection Errors
Error:
Connection timeout or Connection refusedSolutions:- Verify
DATABASE_URLis correct - Check Neon database is active
- Ensure SSL mode is set:
?sslmode=require - Verify Neon’s IP allowlist includes Vercel IPs
Build Failures
Build Failures
Error:
Build failed with exit code 1Solutions:- Check build logs in Vercel dashboard
- Verify all environment variables are set
- Run
npm run buildlocally to reproduce - Check for TypeScript errors
Email Not Sending
Email Not Sending
Error: Emails not being deliveredSolutions:
- Verify
RESEND_API_KEYis correct - Check Resend dashboard for API usage/errors
- Ensure sending domain is verified
- Check spam folder for test emails
CORS Errors
CORS Errors
Error:
CORS policy: No 'Access-Control-Allow-Origin' headerSolutions:- Verify
ALLOWED_ORIGINmatches your actual domain - Check
next.config.tsCORS configuration - Ensure cookies are being sent with requests
Session Errors
Session Errors
Error:
Session expired or Not authenticatedSolutions:- Verify
BETTER_AUTH_SECRETis set - Check
NEXT_PUBLIC_APP_URLmatches deployment URL - Clear browser cookies and try again
- Verify Better Auth tables exist in database
Scaling Considerations
Database Scaling
Neon PostgreSQL auto-scales. For high traffic:- Enable connection pooling in Neon dashboard
- Use read replicas for heavy read operations
- Optimize queries with proper indexes
Vercel Plan Limits
Free Tier Limits
- 100 GB bandwidth/month
- 100 hours function execution/month
- Serverless function timeout: 10 seconds
- Increased bandwidth
- Longer function timeouts
- Team collaboration features
- Advanced analytics
Backup Strategy
Database Backups
Neon provides automatic backups. Verify:
- Go to Neon dashboard → Backups
- Ensure daily backups are enabled
- Configure retention period (7-30 days recommended)
Code Backups
Git provides version control. Additional backups:
- Clone repository locally periodically
- Mirror to a private backup repository
Next Steps
Troubleshooting
Production issues and edge cases
Maintenance
Routine tasks and workflows
