How Code Deployment Happens in Vercel on a very Highlevel
- Connect Repository:- Link your GitHub, GitLab, or Bitbucket repository to Vercel.
- Vercel sets up a webhook to trigger builds automatically on code changes.
 
- Push Code:- When you push code to the repository, Vercel detects the change and triggers a new deployment.
 
- Build Phase:- Vercel pulls the latest code from your repository.
- Runs the buildscript defined in your package.json file.- For example, for Next.js, it runs next build.
 
- For example, for Next.js, it runs 
- Performs the following tasks:- Transpilation: Converts modern JavaScript/TypeScript (ES6+) to browser-compatible versions.
- Bundling: Combines all your code and dependencies into efficient bundles using Webpack/Vite.
- Static Asset Optimization: Optimizes images, fonts, and other static assets.
- Page Generation:- Pre-generates static pages for SSG and ISR.
- Prepares server-side rendered pages for SSR.
 
 
 
- Serverless Function Deployment:- If you have API routes or serverless functions, Vercel packages these into isolated, stateless functions.
- Deploys them to their serverless infrastructure.
 
- Deployment to CDN:- After the build is complete, Vercel uploads your app to its global edge network (CDN).
- Each deployment is immutable and gets a unique URL (e.g., https://projectname.vercel.app).
- For production, a custom domain can be linked.
 
- Caching & Invalidations:- Vercel caches static assets and pre-generated pages for improved performance.
- Automatically invalidates the cache when new deployments occur.
 
- Preview URLs:- Vercel provides a unique preview URL for every branch or pull request.
- Allows developers and stakeholders to preview changes before merging into production.
 
