Skip to main content

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

Or with yarn:
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
The current implementation uses a hardcoded URL. Update it to use environment variables for production.

Build Commands

Development Mode

Run the development server with Turbopack:
The application will be available at http://localhost:3000.

Production Build

1

Build the application

This creates an optimized production build in the .next directory.
2

Start the production server

The server will start on port 3000 by default.

Next.js Configuration

The next.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

1

Install Vercel CLI

2

Deploy to Vercel

Follow the prompts to configure your deployment.
3

Set environment variables

In the Vercel dashboard, add your environment variables:
  • NEXT_PUBLIC_API_URL: Your backend API URL

Docker Deployment

Create a Dockerfile in the frontend directory:
Dockerfile
Build and run the Docker container:

Static Export (Optional)

For static site generation:
1

Update next.config.mjs

next.config.mjs
2

Build static files

Static files will be generated in the 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:
  1. Verify the NEXT_PUBLIC_API_URL environment variable is set correctly
  2. Check CORS settings in the Django backend
  3. 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 to next.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