Development Server
Start the development server to begin working on the project:Development Workflow
Hot Module Replacement (HMR)
Next.js automatically refreshes your browser when you make changes:- React components: Instant updates without losing state
- CSS files: Live reload of styles
- API routes: Automatic restart on changes
You don’t need to manually restart the server when editing files. Changes are reflected immediately in the browser.
Editing Pages
To modify pages:- Navigate to
app/[locale]/directory - Edit the relevant page component
- Save the file
- See changes instantly in your browser
Editing Components
To modify components:- Open files in the
components/directory - Make your changes
- Save the file
- Components using this file will automatically update
Testing Multiple Languages
The application supports internationalization. Test different languages by navigating to:- English:
http://localhost:3000/en - Spanish:
http://localhost:3000/es - Hindi:
http://localhost:3000/hi - Arabic:
http://localhost:3000/ar
Building for Production
Create a Production Build
Build the application for production:- Compiles and optimizes your code
- Generates static pages where possible
- Creates a
.nextdirectory with production assets - Runs
next-sitemapto generate sitemap.xml
The build process may take a few minutes depending on your project size.
Run Production Build Locally
After building, you can test the production build locally:Common Development Tasks
Linting Code
Run ESLint to check for code quality issues:Checking for Build Errors
Before committing code, ensure it builds successfully:Clearing the Cache
If you experience unexpected behavior, try clearing the Next.js cache:.next build directory and forces a fresh build.
Viewing API Routes
API routes are located inapp/api/. Access them at:
app/api/status/route.js, access it at:
Environment-Specific Behavior
Development Mode
When runningnpm run dev:
- Detailed error messages are shown
- Source maps are generated for debugging
- Hot reload is enabled
- Performance is slower than production
Production Mode
When runningnpm start (after npm run build):
- Optimized and minified code
- No source maps (unless configured)
- Faster performance
- Error messages are less detailed
Troubleshooting
Port Already in Use
If port 3000 is already in use, you can specify a different port:Module Not Found Errors
If you encounter module errors, try reinstalling dependencies:Backend Connection Issues
If the frontend can’t connect to the backend:- Verify
NEXT_PUBLIC_BACKEND_URLis set correctly in.env - Ensure the backend server is running
- Check for CORS issues in browser console
- Verify HTTPS/HTTP protocol matching
Next Steps
Now that you can run the project locally:- Start developing new features
- Test your changes across different languages
- Build and deploy to production when ready
