Vercel deployment (recommended)
Daily GeoGame is optimized for deployment on Vercel, the platform built by the creators of Next.js.1
Push to GitHub
Ensure your code is pushed to a GitHub repository:
2
Import to Vercel
Go to vercel.com and sign in with your GitHub account. Click “Add New Project” and import your repository.
3
Configure project settings
Vercel will automatically detect that this is a Next.js project. The default settings should work:
- Framework Preset: Next.js
- Build Command:
next build --turbopack(from package.json) - Output Directory:
.next(auto-detected) - Install Command:
pnpm install(auto-detected)
4
Add environment variables
Before deploying, add your MongoDB connection string:
- Go to “Environment Variables” section
- Add
MONGODB_URIwith your MongoDB Atlas connection string - Select all environments (Production, Preview, Development)
5
Deploy
Click “Deploy” and Vercel will build and deploy your application. Your app will be live at a
*.vercel.app URL.The live demo is hosted at https://daily-geogame.vercel.app
Environment variables in production
Required variables
Set these environment variables in your deployment platform:Setting variables on Vercel
1
Navigate to project settings
Go to your project dashboard on Vercel and click “Settings”.
2
Add environment variables
Click “Environment Variables” in the sidebar and add your variables:
- Key:
MONGODB_URI - Value: Your MongoDB connection string
- Environments: Select Production, Preview, and Development
3
Redeploy
If you add variables after initial deployment, trigger a new deployment for changes to take effect.
MongoDB Atlas production setup
For production deployments, configure MongoDB Atlas with enhanced security:1
Use a production cluster
Create a separate production cluster, distinct from your development database. Consider upgrading from the free M0 tier for better performance.
2
Configure IP whitelist
Restrict access to Vercel’s IP addresses:
- In MongoDB Atlas, go to “Network Access”
- Add Vercel’s IP ranges or use 0.0.0.0/0 (less secure but easier)
- For tighter security, use Vercel’s static IP addresses if available on your plan
3
Set up database user
Create a production-specific database user:
- Use a strong, unique password
- Grant only necessary permissions (readWrite on your database)
- Store credentials securely in environment variables
4
Enable monitoring
Enable MongoDB Atlas monitoring and set up alerts for:
- Connection spikes
- High CPU usage
- Storage threshold warnings
Build process
The build process compiles your Next.js application for production:next build --turbopack, which:
- Compiles TypeScript to JavaScript
- Optimizes React components
- Generates static pages where possible
- Creates optimized bundles with Turbopack
Build output
After a successful build, you’ll see output similar to:Starting the production server
For custom hosting, start the production server after building:next start, which serves the built application on port 3000.
On Vercel, this step is handled automatically. You only need this for self-hosting.
Custom domain setup
To use a custom domain with your Vercel deployment:1
Add domain in Vercel
Go to your project settings → “Domains” and add your custom domain.
2
Configure DNS
Add DNS records to your domain provider:
- Type: A or CNAME
- Name: @ (or your subdomain)
- Value: Provided by Vercel
3
Verify and enable HTTPS
Vercel will automatically verify your domain and provision SSL certificates. This usually takes a few minutes.
Alternative deployment platforms
Self-hosting with Docker
For self-hosting, create aDockerfile:
Other platforms
Daily GeoGame can be deployed to any platform that supports Next.js:- Netlify: Use the Next.js build plugin
- Railway: Auto-detects Next.js, add environment variables
- DigitalOcean App Platform: Import from GitHub, configure build settings
- AWS Amplify: Import repository and set build configuration
- Set
MONGODB_URIenvironment variable - Use Node.js 20.x or higher
- Install pnpm or configure the platform to use it
- Use build command:
pnpm build - Use start command:
pnpm start
Monitoring and logs
Vercel monitoring
Vercel provides built-in monitoring:- Real-time logs: View deployment and runtime logs in the dashboard
- Analytics: Track page views and performance (requires upgrade)
- Error tracking: See runtime errors and stack traces
- Go to your project → “Deployments”
- Click on a deployment to view its logs
- Use “Runtime Logs” for live application logs
MongoDB Atlas monitoring
Monitor your database:- Performance: View query performance and slow queries
- Connections: Track connection count and patterns
- Storage: Monitor database size and growth
- Alerts: Set up email alerts for issues
Production checklist
Before going live, verify:- MongoDB connection string is set in environment variables
- Using production MongoDB cluster (not development)
- MongoDB network access is properly configured
- Database user has appropriate permissions
- Build completes without errors
- All required dependencies are in
package.json -
.env.localis in.gitignore - Custom domain is configured (if applicable)
- SSL certificate is active
- Monitoring and alerts are enabled
Troubleshooting
Build failures
If your build fails:- Check the build logs for TypeScript errors
- Ensure all dependencies are listed in
package.json - Verify Node.js version is 20.x or higher
- Try building locally first:
pnpm build
MongoDB connection errors
If you see database connection errors:- Verify
MONGODB_URIis set correctly - Check MongoDB Atlas network access settings
- Ensure database user credentials are correct
- Test connection string locally
Performance issues
If your application is slow:- Check MongoDB Atlas performance metrics
- Consider upgrading from M0 tier
- Add database indexes for frequently queried fields
- Enable Vercel Analytics to identify bottlenecks
Next steps
After deployment:- Monitor your application’s performance
- Set up error tracking (Sentry, LogRocket, etc.)
- Configure continuous deployment for automatic updates
- Review and optimize database queries