Prerequisites
Before deploying the frontend, ensure you have:- Node.js 20 or later installed
- npm, pnpm, or yarn package manager
- Access to the PostgreSQL database configured for the backend
- Git installed for cloning the repository
Installation
Install dependencies
Install the required npm packages:Key dependencies include:
- Next.js 15.1.11
- React 19.0.0
- PostgreSQL client (pg)
- Mailparser for email parsing
- Tailwind CSS for styling
- Radix UI components
- Framer Motion for animations
Configure environment variables
Create a Add the required environment variables:
.env.local file in the UI directory:The
DATABASE_URL should point to the same PostgreSQL database used by the backend.Development server
To run the development server with Turbopack:http://localhost:3000.
Production deployment
Running locally
After building, start the production server:Deploy to Vercel
Vercel is the recommended platform for deploying Next.js applications:Set environment variables
In the Vercel dashboard, navigate to your project settings and add:
DATABASE_URL: Your PostgreSQL connection string
Deploy to Railway
Railway provides simple deployment with automatic GitHub integration:Deploy to other platforms
Database connection
The frontend connects to PostgreSQL using thepg library (ui/src/lib/db.ts:1-6):
Next.js configuration
The application uses a minimal Next.js configuration (ui/next.config.ts:1-10):Available scripts
The following scripts are available inpackage.json:
dev- Start development server with Turbopackbuild- Create production buildstart- Start production serverlint- Run ESLint for code quality
Features
The Zapmail frontend includes:- Temporary email generation: Create disposable email addresses
- Inbox management: View and manage received emails
- Email parsing: Parse and display HTML/plain text emails using mailparser
- Responsive design: Mobile-friendly interface with Tailwind CSS
- Real-time updates: Check for new emails automatically
- Animated UI: Smooth animations with Framer Motion
Troubleshooting
Build errors
If you encounter build errors:- Clear the Next.js cache:
rm -rf .next - Delete
node_modulesand reinstall:rm -rf node_modules && npm install - Ensure you’re using Node.js 20 or later
Database connection errors
If the frontend can’t connect to the database:- Verify
DATABASE_URLis set correctly in.env.local - Test the connection string with
psql - Ensure the database allows connections from your deployment platform
- Check that the
emailstable exists
Environment variables not loading
Next.js environment variables:- Use
.env.localfor local development - Prefix client-side variables with
NEXT_PUBLIC_ - Server-side variables (like
DATABASE_URL) don’t need a prefix - Restart the development server after changing environment variables
The
DATABASE_URL is only used server-side and will never be exposed to the client.Next steps
Configuration
Learn about all available environment variables and configuration options