Overview
The Password Generator frontend is built with Next.js 16 and uses modern React features. This guide covers deploying the frontend application to production.Prerequisites
- Node.js 18.x or higher
- npm or yarn package manager
- Backend API URL (deployed Django backend)
Dependencies
The frontend uses the following key dependencies:package.json
Installation
1
Clone the repository
2
Install dependencies
3
Configure environment variables
Create a
.env.local file in the frontend directory:.env.local
Environment variables prefixed with
NEXT_PUBLIC_ are exposed to the browser.4
Update API configuration
Edit
src/app/utils/Request.api.js to use environment variables:src/app/utils/Request.api.js
Build Commands
Development Mode
Run the development server with Turbopack:http://localhost:3000.
Production Build
1
Build the application
.next directory.2
Start the production server
Next.js Configuration
Thenext.config.mjs file contains the application configuration:
next.config.mjs
Add your production domain to the
images.domains array if you’re using Next.js Image optimization.Deployment Platforms
Vercel (Recommended)
1
Install Vercel CLI
2
Deploy to Vercel
3
Set environment variables
In the Vercel dashboard, add your environment variables:
NEXT_PUBLIC_API_URL: Your backend API URL
Docker Deployment
Create aDockerfile in the frontend directory:
Dockerfile
Static Export (Optional)
For static site generation:1
Update next.config.mjs
next.config.mjs
2
Build static files
out directory.3
Deploy static files
Upload the
out directory to any static hosting service (Netlify, GitHub Pages, etc.).Post-Deployment
Verify Deployment
1
Test the application
Visit your deployed URL and verify:
- Homepage loads correctly
- Password generation works
- User authentication functions
2
Check API connectivity
Open browser DevTools and check the Network tab to ensure API requests are successful.
3
Test responsive design
Verify the application works on mobile and desktop devices.
Troubleshooting
API Connection Issues
If the frontend cannot connect to the backend:- Verify the
NEXT_PUBLIC_API_URLenvironment variable is set correctly - Check CORS settings in the Django backend
- Ensure the backend API is accessible from your deployment environment
Build Failures
If the build fails:Image Optimization Errors
If you encounter image optimization errors, add your image domains tonext.config.mjs:
Performance Optimization
- Enable caching headers for static assets
- Use a CDN for serving static files
- Enable compression (gzip/brotli)
- Monitor with Next.js Analytics or similar tools
Next Steps
Backend Deployment
Deploy the Django backend API
Environment Configuration
Configure environment variables
