Why Vercel?
Vercel is the platform created by the Next.js team and offers:- Zero-config deployment for Next.js apps
- Automatic HTTPS and SSL certificates
- Edge network for global performance
- Serverless functions for API routes
- Environment variable management
- Preview deployments for every Git push
SkyCast IA can also be deployed to other platforms like Railway, Netlify, or Docker, but Vercel provides the best Next.js experience.
Prerequisites
Before deploying, ensure you have:- A GitHub, GitLab, or Bitbucket account
- Your code pushed to a Git repository
- All API keys ready (see API Keys Setup)
- A Vercel account (sign up at vercel.com)
Deployment Steps
1. Push Code to Git Repository
Ensure your code is committed and pushed to GitHub, GitLab, or Bitbucket:2. Import Project to Vercel
- Visit vercel.com/new
- Click Import Git Repository
- Select your repository from the list
- Click Import
3. Configure Project Settings
Vercel should auto-detect Next.js. If not, select it manually.
Leave as default unless your Next.js app is in a subdirectory.
Default command is fine. Override only if you have custom build scripts.
Next.js default output directory.
4. Add Environment Variables
In the Vercel project settings:- Scroll to Environment Variables
- Add each variable from your
.env.localfile - Set the environment to Production (and optionally Preview/Development)
Use production-specific API keys, not your development keys. This improves security and helps track usage separately.
5. Deploy
- Click Deploy
- Vercel will build and deploy your application
- Wait 1-3 minutes for the deployment to complete
- You’ll receive a production URL (e.g.,
skycast-ia.vercel.app)
Post-Deployment Configuration
Update reCAPTCHA Domains
- Visit Google reCAPTCHA Admin
- Select your site
- Click Settings
- Add your Vercel domain to Domains:
your-project.vercel.app- Any custom domains you’ve configured
Verify Deployment
Test your production deployment:- Visit your Vercel URL
- Check that weather data loads
- Test city search
- Verify AI analysis appears
- Open the chat and complete reCAPTCHA
- Send a chat message
- Check that news articles load
Build Configuration
next.config.ts
SkyCast IA’s build configuration (next.config.ts:1):
Update Allowed Origins for Production
Add your production domain toallowedOrigins:
Performance Optimization
Edge Functions
Vercel automatically deploys Next.js API routes as serverless functions. For better global performance, consider converting critical routes to Edge Runtime:When to Use Edge Runtime
When to Use Edge Runtime
Best for:
- Lightweight API routes
- Real-time data fetching
- Geolocation-based logic
- Authentication checks
- Heavy computations
- Large dependencies
- File system operations
Caching Strategy
Implement caching for weather data to reduce API calls:Cache duration in seconds (10 minutes recommended for weather data)
Serve stale content while revalidating in background (5 minutes)
Custom Domain Setup
Add Custom Domain
- Go to your Vercel project Settings
- Navigate to Domains
- Enter your custom domain (e.g.,
skycast.com) - Follow DNS configuration instructions
Update DNS Records
Add these records to your DNS provider: For root domain (skycast.com):DNS propagation can take up to 48 hours, but usually completes within a few minutes.
Environment-Specific Configuration
Development vs Production
Use different environment variables for each environment:Preview Deployments
Vercel creates a preview deployment for every Git push:- Production: Deployed from
mainormasterbranch - Preview: Deployed from feature branches
- Development: Local environment only
- Vercel Dashboard → Settings → Environment Variables
- Select target environments: Production, Preview, or Development
Monitoring & Analytics
Vercel Analytics
Enable Vercel Analytics for performance insights:-
Install the package:
-
Add to
src/app/layout.tsx:
Error Tracking
Monitor errors in Vercel Dashboard:- Navigate to Logs to view runtime errors
- Check Functions for API route performance
- Review Build Logs for deployment issues
Troubleshooting
Build Fails with TypeScript Errors
Build Fails with TypeScript Errors
Cause:
ignoreBuildErrors is disabled and there are type errorsSolutions:- Fix TypeScript errors in your code
- Temporarily enable
ignoreBuildErrorsinnext.config.ts - Check build logs for specific error messages
Environment Variables Not Working
Environment Variables Not Working
Cause: Variables not set in Vercel or incorrect namingSolutions:
- Verify all variables are added in Vercel Dashboard
- Check for typos in variable names
- Ensure
NEXT_PUBLIC_prefix for client-side variables - Redeploy after adding new variables
reCAPTCHA Fails in Production
reCAPTCHA Fails in Production
Cause: Production domain not whitelistedSolutions:
- Add Vercel domain to reCAPTCHA admin console
- Wait a few minutes for changes to propagate
- Clear browser cache and test again
API Rate Limits Exceeded
API Rate Limits Exceeded
Cause: High traffic hitting API limitsSolutions:
- Implement caching (see Performance Optimization)
- Upgrade to paid API plans
- Monitor usage in provider dashboards
- Implement request throttling
Slow API Responses
Slow API Responses
Cause: Cold starts on serverless functionsSolutions:
- Consider using Edge Runtime for critical routes
- Implement caching strategies
- Optimize API call frequency
- Use Vercel Pro for faster cold starts
Continuous Deployment
Vercel automatically deploys when you push to Git:Deployment Protection
Enable deployment protection for production:- Vercel Dashboard → Settings → Deployment Protection
- Enable Vercel Authentication
- Add team members who can bypass protection
Rollback Strategy
If a deployment introduces issues:- Go to Vercel Dashboard → Deployments
- Find the last working deployment
- Click the ⋯ menu
- Select Promote to Production
Rolling back is instant and doesn’t require a new build.
Next Steps
Environment Variables
Review the complete environment variables reference.
API Keys Setup
Learn how to obtain and configure all required API keys.
Vercel Documentation
Explore advanced Vercel features and configuration options.
