Deploy a GitHub repo to Vercel for the first time
When to use this: Your code is on GitHub and you want it live on a *.vercel.app URL that redeploys on every push.
Before you start
Steps
-
Start a new project
In the Vercel dashboard click 'Add New...' then 'Project'. Under 'Import Git Repository' choose GitHub.
-
Authorise the GitHub app
If your repo is not listed, click 'Adjust GitHub App Permissions' and give Vercel access to this repo (or all repos). Then click 'Import' next to it.
-
Check the detected settings
Vercel detects the framework (Astro for this site). Defaults: build command
npm run build, output directorydist(Astro), install commandnpm install. Leave them unless something is wrong. Add environment variables now if the site needs them. -
Deploy
Click 'Deploy'. The first build takes about a minute, then you get a URL like
my-site.vercel.app. -
From now on, deploys happen on push
terminalgit add -A git commit -m "Update content" git pushPushing to
maincreates a Production deployment. Pushing any other branch creates a Preview deployment.
How to verify it worked
- The project's Deployments tab shows a green 'Ready' deployment and the URL opens your site.
How to undo it
To unlink: Project, Settings, Git, 'Disconnect'. To delete the whole project: Settings, scroll to 'Delete Project'. Your GitHub repo is not affected.
Common errors and fixes
Command "npm run build" exited with 1 Open the failed deployment's build log (see the build-log scenario). Reproduce locally with npm run build. dist; for Next.js leave it empty. Check Settings, Build and Deployment. Q&A
Do I need a vercel.json?
Not for a standard Astro, Next.js or Vite project. Vercel detects the framework. Add vercel.json only for redirects, headers, or custom build settings.
Does Vercel read my code from my PC?
No. It builds from GitHub, so only what you pushed is deployed.