This guide provides step-by-step instructions for deploying the Devoby waste management application to Vercel.
Before you begin, ensure you have:
- A Vercel account
- A GitHub account (or GitLab/BitBucket)
- Your project code pushed to a Git repository
- All required API keys and environment variables
- Log in to your Vercel dashboard
- Click the "Add New..." button and select "Project"
- Import your Git repository:
- Select your Git provider (GitHub, GitLab, or BitBucket)
- Authenticate with your Git provider if prompted
- Find and select the Devoby repository
- Project Name: Enter a name for your project (e.g., "devoby")
- Framework Preset: Vercel should automatically detect Next.js
- Root Directory: Leave as default if your project is in the root of the repository
- Build and Output Settings: The default settings should work for a standard Next.js project
Add the following environment variables in the Vercel project settings:
```
FIREBASE_API_KEY=your_firebase_api_key FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain FIREBASE_PROJECT_ID=your_firebase_project_id FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id FIREBASE_APP_ID=your_firebase_app_id
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_google_maps_api_key
MTN_MOBILE_MONEY_API_KEY=your_mtn_api_key ORANGE_MONEY_API_KEY=your_orange_api_key ```
Important: Variables that need to be accessible in the browser must be prefixed with NEXT_PUBLIC_.
- Click the "Deploy" button
- Wait for the build and deployment process to complete
- Once deployed, Vercel will provide a URL to access your application
- In your project dashboard, go to the "Domains" tab
- Click "Add" and enter your domain name
- Follow the instructions to configure DNS settings for your domain
Vercel automatically sets up continuous deployment from your Git repository:
- New commits to the main branch will trigger a new production deployment
- Pull requests will create preview deployments
Vercel provides different environments for different stages of your deployment:
- Production: Deployments from the main branch
- Preview: Deployments from pull requests
- Development: Your local development environment
You can configure environment-specific variables in the Vercel dashboard by selecting the appropriate environment when adding variables.
- Deployment Status: View the status of your deployments in the "Deployments" tab
- Logs: Access build and runtime logs for each deployment
- Analytics: Enable Vercel Analytics to track performance and usage metrics
Next.js API routes are deployed as serverless functions on Vercel. Consider these limitations:
- Execution timeout: 10 seconds for Hobby tier, 60 seconds for Pro tier
- Payload size limits: 4.5MB for Hobby tier, 5MB for Pro tier
- Memory: 1024MB for Hobby tier, configurable for Pro tier
Vercel's edge network automatically caches and serves static assets globally. To optimize performance:
- Use static generation for pages when possible
- Implement Incremental Static Regeneration for dynamic content
- Configure caching headers appropriately
Symptom: Deployment fails during the build process
Solution:
- Check the build logs for specific errors
- Ensure all dependencies are correctly listed in
package.json - Verify that your code works in the local development environment
Symptom: Features dependent on environment variables don't work
Solution:
- Verify that all required environment variables are set in the Vercel dashboard
- Ensure client-side variables are prefixed with
NEXT_PUBLIC_ - Check for typos in variable names
Symptom: APIs work locally but fail in production
Solution:
- Check if your API keys have domain restrictions
- Update API settings to allow requests from your Vercel