Deployment
Learn how we deploy our website to production with Vercel
Deployment is the process of putting your code live on the internet so users can access it. We use Vercel, which handles deployment automatically when we push code to GitHub.
How Deployment Works
What is Vercel?
What: Vercel is a cloud platform for hosting web applications. It's made by the same company that created Next.js.
Why we use it: Vercel automatically builds and deploys our website whenever we push code to GitHub. No manual deployment needed!
Key feature: Every pull request gets its own preview URL so you can test changes before merging.
๐ Official Documentation:
Vercel DocumentationThe Deployment Workflow
Here's what happens when you make changes to the codebase:
Create a Branch and Make Changes
You create a new Git branch and make your code changes locally.
Create a Pull Request
You open a pull request (PR) on GitHub to merge your changes into the main branch.
Vercel Creates a Preview Deployment
Vercel automatically builds your code and creates a unique preview URL (e.g., gdg-website-abc123.vercel.app). This lets you test your changes before merging.
Check the Preview
Click the Vercel preview link in your PR. Make sure everything works correctly!
โ ๏ธ IMPORTANT: Always check that the preview deployment succeeds and works as expected.
Merge to Main
Once the preview looks good and your PR is approved, merge it into the main branch.
Vercel Deploys to Production
Vercel automatically deploys the main branch to production (the live website). Your changes are now live!
What Happens During Build
When Vercel deploys your code, it runs npm run build. This command:
- Compiles TypeScript to JavaScript
- Bundles and minifies all code (makes it smaller and faster)
- Optimizes CSS and images
- Pre-renders static pages
- Checks for type errors and other issues
โ ๏ธ If the build fails:
- Check the Vercel logs to see the error message
- Run
npm run buildlocally to reproduce the error - Fix the error in your code
- Push the fix and Vercel will automatically retry
Test the build locally:
Run npm run build โ if it succeeds locally, it should succeed on Vercel.
Environment Variables
What: Environment variables are secret values (like Firebase API keys) that your app needs to run.
Why: We store these separately (not in the code) for security. Different environments (production, preview, development) can have different values.
How to add environment variables on Vercel:
- Go to your project on vercel.com
- Click Settings โ Environment Variables
- Add each variable (name and value)
- Select which environments need it: Production, Preview, and/or Development
- Click Save
Our required environment variables:
Check .env.local.example in the project root for the full list of required Firebase environment variables.
Edge Runtime Limitations
Our backend routes run on Vercel's Edge Runtime, which is a lightweight JavaScript environment. It's fast and globally distributed, but has some limitations:
โ What you CANNOT do on the Edge:
- File system operations โ No reading/writing files with
fs - WebSockets or Socket.io โ No persistent connections
- In-memory caching โ State doesn't persist between requests
- Some Node.js APIs โ Only a subset is available
- Long-running processes โ Requests timeout after a certain duration
โ What you CAN do:
- Fetch data from APIs (including Firebase)
- Process HTTP requests and return responses
- Run middleware and authentication checks
- Use most modern JavaScript features
๐ Learn more:
Next.js โ Edge and Node.js RuntimesDebugging Failed Deployments
If your deployment fails, here's how to debug it:
- Check Vercel Logs
Click on the failed deployment in Vercel to see the error logs. The error message will tell you what went wrong.
- Reproduce Locally
Run
npm run buildon your computer. If it fails locally, you can debug more easily. - Common Issues
- TypeScript errors (type mismatches, missing properties)
- Missing dependencies in
package.json - Environment variables not set correctly
- Import errors (wrong file paths, missing files)
- Fix and Push
Once you fix the issue, commit and push. Vercel will automatically retry the deployment.
โ Deployment Checklist
Before merging your PR, make sure:
- โ The Vercel preview deployment succeeds (green checkmark on GitHub)
- โ You've clicked the preview link and tested your changes
- โ No TypeScript errors or warnings
- โ
npm run buildsucceeds locally - โ Your PR has been reviewed and approved