Prerequisites
Ensure you have:- Node.js 20+ installed
- npm, yarn, pnpm, or bun package manager
- Backend API running and accessible
See the Prerequisites page for installation instructions.
Clone Repository
Install Dependencies
The frontend uses several key dependencies:- Next.js 16.1.6 - React framework
- React 19.2.3 - UI library
- Babylon.js 8.51.2 - 3D surgical simulation
- STOMP/WebSocket - Real-time telemetry
- Tailwind CSS - Styling
- TypeScript 5 - Type safety
Configure Environment
Create Environment File
Create.env.local in the frontend directory:
.env.local
Variables prefixed with
NEXT_PUBLIC_ are exposed to the browser.Environment Variables
| Variable | Description | Default | Required |
|---|---|---|---|
NEXT_PUBLIC_API_URL | Backend REST API URL | http://localhost:8080 | Yes |
NEXT_PUBLIC_WS_URL | WebSocket server URL | ws://localhost:8080 | Yes |
Production Configuration
For production deployment:.env.production
Development Server
Run the development server with hot reload:The page auto-updates as you edit files. The development server uses React Fast Refresh.
Production Build
Build Application
Create an optimized production build:- Compiles TypeScript
- Bundles and minifies JavaScript
- Optimizes images and assets
- Generates static pages where possible
- Creates
.next/build directory
Start Production Server
After building, start the production server:Custom Port
Deployment Options
Vercel (Recommended)
Vercel is the easiest deployment option for Next.js applications:Deploy
- Link to your Vercel account
- Configure project settings
- Set environment variables
Vercel automatically detects Next.js and configures optimal settings.
Node.js Server
Deploy on any Node.js hosting:Upload Files
Transfer these directories to your server:
.next/public/package.jsonnext.config.ts.env.production
PM2 Process Manager
Use PM2 for production process management:Docker Deployment
CreateDockerfile in frontend directory:
Static Export
For static hosting (Nginx, Apache, S3): Modifynext.config.ts:
next.config.ts
out/ directory contains static files ready for deployment.
Nginx Configuration
Example Nginx configuration for reverse proxy:Verify Deployment
Test Backend Connection
Verify the frontend can connect to the backend API.Check browser console for errors:
Troubleshooting
API Connection Errors
API Connection Errors
Check Verify backend is accessible:Check CORS configuration on backend.
NEXT_PUBLIC_API_URL is correct:WebSocket Connection Failed
WebSocket Connection Failed
Ensure backend WebSocket endpoint is accessible:Check firewall rules allow WebSocket connections.Verify JWT token is being sent correctly.
3D Scene Not Loading
3D Scene Not Loading
Babylon.js requires WebGL support. Check browser compatibility:Verify 3D model files are accessible in
public/ directory.Build Failures
Build Failures
Clear cache and rebuild:Check TypeScript errors:
Performance Optimization
Image Optimization
Next.js automatically optimizes images. Use the<Image> component:
Font Optimization
The project uses Next.js font optimization with Geist:Monitoring and Logs
PM2 Logs
Next.js Logs
Next Steps
After deploying the frontend:- Deploy Backend - Ensure backend is running
- Deploy AI Service - Deploy AI analysis service
- Configure SSL certificates
- Set up CDN for static assets
- Configure monitoring and analytics
- Set up error tracking (Sentry, LogRocket)
Additional Resources
- Environment Variables - Configuration reference
- Next.js Documentation - Official Next.js docs
- Vercel Deployment - Vercel deployment guide
- Frontend dependencies:
package.json - Tech stack: Next.js 16, React 19, TypeScript 5, Babylon.js 8