Prerequisites
Before deploying the frontend, ensure you have:- Node.js 20.x or higher
- pnpm 9.0.0 or higher (recommended package manager)
- Backend server deployed and accessible (see Backend Setup)
Installation
Install dependencies
The project uses pnpm as the package manager:If you don’t have pnpm installed:
Key Dependencies
The frontend uses these major technologies:- Next.js 16.1.1 - React framework with App Router
- React 19.2.3 - UI library
- TypeScript - Type safety
- TanStack Query - Data fetching and caching
- Axios - HTTP client
- Radix UI - Accessible component primitives
- Tailwind CSS - Utility-first styling
- Framer Motion - Animations
- Lucide React - Icon library
- Sonner - Toast notifications
Configure environment variables
Create a Add the required environment variable:See Environment Variables for production configuration.
.env.local file in the apps/web directory:Development Mode
Run the development server with hot-reloading:http://localhost:3000.
Development Features
- Hot Module Replacement (HMR)
- Fast Refresh for React components
- TanStack Query DevTools (automatically enabled in development)
- TypeScript error checking
- ESLint integration
Production Build
Build the application
Create an optimized production build:This will:
- Compile TypeScript
- Bundle JavaScript and CSS
- Optimize images and assets
- Generate static pages where possible
- Create server-side rendering bundles
Deployment Options
Deploy to Vercel (Recommended)
Vercel is the recommended platform for Next.js applications.Vercel automatically detects Next.js and configures optimal build settings.
Deploy to Netlify
Deploy with Docker
Create aDockerfile in the apps/web directory:
next.config.ts to enable standalone output:
Deploy to Static Hosting
For static export (if your app doesn’t require SSR):Configuration
API Base URL
The frontend communicates with the backend via theNEXT_PUBLIC_API_URL environment variable.
Development:
Ensure the URL ends with a trailing slash
/Authentication Flow
The frontend uses JWT tokens stored in cookies:- User logs in via
/loginor/signup - OAuth redirect to backend (
/auth/google) - Backend redirects back with JWT in URL
- Frontend stores JWT in cookie
- All API requests include JWT in Authorization header
Axios Configuration
The app uses a custom Axios instance (lib/api.ts):
Performance Optimization
Image Optimization
Use Next.js<Image> component for automatic optimization:
Code Splitting
Next.js automatically code-splits by route. For additional splitting:Caching Strategy
TanStack Query handles data caching:Security Best Practices
Content Security Policy
Add CSP headers innext.config.ts:
Troubleshooting
Build Errors
TypeScript errors:Runtime Issues
API connection fails:- Verify
NEXT_PUBLIC_API_URLis set correctly - Check CORS configuration on backend
- Ensure backend is running and accessible
- Check JWT cookie is being set
- Verify backend OAuth configuration
- Check browser console for errors
Performance Issues
Slow page loads:- Enable Next.js Analytics (Vercel)
- Use React DevTools Profiler
- Check TanStack Query DevTools for excessive requests
- Optimize images and reduce bundle size
Monitoring
Analytics
Add Vercel Analytics:Error Tracking
Integrate Sentry or similar:Next Steps
- Backend Setup - Deploy the Node.js server
- Environment Variables - Complete configuration reference
- Google OAuth - Set up authentication