Overview
BeeHex is a Next.js 14 application optimized for deployment on modern hosting platforms. This guide covers deployment options, configuration, and best practices.Prerequisites
Before deploying, ensure:- Your code is committed to a Git repository
- All tests pass locally
- Production environment variables are configured
- Game server backend is deployed and accessible
Deployment Options
Vercel (Recommended)
Vercel is the recommended platform for deploying BeeHex, created by the makers of Next.js.1
Connect Repository
- Go to vercel.com
- Click “New Project”
- Import your BeeHex repository
2
Configure Project
Vercel auto-detects Next.js projects. Verify settings:
- Framework Preset: Next.js
- Build Command:
npm run build - Output Directory:
.next - Install Command:
npm install
3
Set Environment Variables
Add production environment variables:
Since BeeHex uses
src/env/env.ts for configuration, you’ll need to modify this file or use a build-time script to inject production values.4
Deploy
Click “Deploy”. Vercel will:
- Install dependencies
- Build your Next.js application
- Deploy to a global CDN
- Provide a production URL
Vercel Features
Automatic Deployments
Every push to your main branch triggers a new deployment
Preview Deployments
Pull requests get unique preview URLs for testing
Edge Network
Global CDN for fast loading worldwide
Zero Configuration
Automatic optimization for Next.js apps
Netlify
Deploy BeeHex on Netlify with automatic builds:1
Create New Site
- Log in to netlify.com
- Click “Add new site” → “Import an existing project”
- Connect your Git repository
2
Configure Build Settings
3
Add Environment Variables
In Site settings → Environment variables, configure your production settings.
4
Deploy
Click “Deploy site” to trigger your first deployment.
Netlify provides automatic HTTPS, continuous deployment, and branch previews.
Docker Container
Deploy BeeHex as a Docker container for self-hosted environments:1
Create Dockerfile
Create a
Dockerfile in your project root:Dockerfile
2
Build Docker Image
3
Run Container
4
(Optional) Use Docker Compose
Create Run with:
docker-compose.yml:docker-compose.yml
Traditional Hosting (VPS)
Deploy on a VPS (DigitalOcean, AWS EC2, etc.):1
Prepare Server
Install Node.js 20+ on your server:
2
Clone Repository
3
Install Dependencies
4
Configure Environment
Create production environment configuration:
src/env/env.ts
5
Build Application
6
Start with PM2
Use PM2 for process management:
7
Configure Nginx Reverse Proxy
Create Nginx configuration:Enable site:
/etc/nginx/sites-available/beehex
8
Setup SSL with Let's Encrypt
Build Optimization
Production Build
Create an optimized production build:- Compiles TypeScript to JavaScript
- Minifies JavaScript and CSS
- Optimizes images and fonts
- Generates static pages where possible
- Creates production bundles in
.next/
Build Output
Environment Configuration
Production Environment
For production, modifysrc/env/env.ts:
Environment Variable Best Practices
- Never commit secrets to version control
- Use different values for development, staging, and production
- Prefix client-side variables with
NEXT_PUBLIC_in Next.js - Document all required variables in your README
Performance Optimization
Next.js Optimizations
BeeHex leverages Next.js built-in optimizations:Automatic Code Splitting
Each route only loads necessary code
Image Optimization
Automatic image resizing and WebP conversion
Font Optimization
Self-hosted fonts with zero layout shift
Script Optimization
Optimized third-party script loading
Additional Optimizations
1
Enable Compression
Next.js automatically gzip/brotli compresses responses in production.
2
Configure Caching
Set appropriate cache headers for static assets:
next.config.mjs
3
Analyze Bundle Size
next.config.mjs:Monitoring & Logging
Application Monitoring
Monitor your production deployment:- Vercel Analytics: Built-in analytics for Vercel deployments
- Google Analytics: Track user behavior
- Sentry: Error tracking and performance monitoring
- LogRocket: Session replay and debugging
Health Checks
Implement health check endpoints:src/app/api/health/route.ts
Rollback Strategy
Vercel Rollback
- Go to your project dashboard
- Click “Deployments”
- Find the previous working deployment
- Click ”⋯” → “Promote to Production”
Manual Rollback
Continuous Deployment
GitHub Actions
Automate deployments with GitHub Actions:.github/workflows/deploy.yml
Security Considerations
Security Headers
Add security headers innext.config.mjs:
Troubleshooting
Build Fails
Issue: Build fails with TypeScript errorsWebSocket Connection Issues
Issue: Can’t connect to game server in production- Verify
IP_HOSTinsrc/env/env.tspoints to production server - Ensure game server allows connections from your domain
- Check CORS configuration on game server
- Use WSS (secure WebSocket) for HTTPS sites
Memory Issues
Issue: Build runs out of memoryNext Steps
Architecture Overview
Understand the system architecture
Game Engine
Learn about the game engine implementation
WebSocket Protocol
Explore the real-time communication protocol
Contributing
Contribute to the project