By the end of this lesson you will test every change on its own preview link first, and send it to the live site only after it works.
You need: an app that already deploys to Vercel from GitHub (see Test and go live), Git save points (Never lose your work), your coding agent · Time: 8 minutes
In this course we follow one real-looking app: a fee tracker for Sharma Coaching, a coaching institute with 120 students. Mr Sharma's office uses it every day, and parents open it to check what is due. You built it with Next.js and Supabase and deployed it like in Build your first web MVP.
Right now every push to
maingoes live in a minute or two. That was fine for a demo. Now a small mistake at 9 am on fee day means a blank page and twenty phone calls.Vercel gives every deployment one of two jobs:
- Production: the version on your main address. Vercel makes it when you push or merge into the production branch, usually
main. - Preview: a full working copy of the app at its own address. Vercel makes one when you push any other branch or open a pull request. Real users never see it unless you send them the link.
Other branches become previews. Only main becomes production. Why?A preview is the live app minus the risk. You see the change on a real phone, on real Vercel servers, before a single parent sees it.
- Production: the version on your main address. Vercel makes it when you push or merge into the production branch, usually
A branch is a parallel copy of your code where you can try a change without touching
main. A pull request (PR) is a page on GitHub that asks "please merge this branch into main" and shows exactly what changed.Ask your agent to do the Git part for you:
Prompt · copy it into your AI agentI want to build a feature on a separate Git branch so Vercel makes a preview before it goes live. 1. Check that git status is clean. If it is not, tell me what is changed and stop. 2. Create and switch to a new branch called [fee-reminder]. 3. Build this: [on the Students page, show a red "Fee due" badge next to every student whose fee for this month is not marked paid]. 4. Run npm run build and show me the result. Fix any error before you commit. 5. Commit with a clear message and push the branch to GitHub. 6. Give me the GitHub link to open a pull request for this branch. Do not merge anything.
You will see commands like these in the agent's output (same on Windows, macOS and Linux):
Open that link and click Create pull request. A minute later the Vercel bot adds a comment to the pull request with a Visit Preview link. You also find every preview in your Vercel project under Deployments.
Why?The agent is fast at Git commands; you stay in charge of the one step that matters, the merge. Asking it to run
npm run buildfirst catches most errors before Vercel even starts.Two kinds of preview links exist. The branch link (it has
-git-fee-reminder-in the name) always shows the newest push on that branch. The commit link stays fixed to one exact version, which is handy for "this is what I tested".Things to know before you share it:
- Previews are private by default on new Vercel projects. Anyone opening the link must log in with a Vercel account that has access. To show Mr Sharma, use Vercel's Shareable Link feature or approve his access request.
- Search engines skip previews. Vercel marks them "noindex", so a half-finished feature does not end up on Google.
- Previews use Preview settings, not Production ones. In the next lesson you point previews at a test database, so testing never touches real fee records.
Do it now Test the preview before you merge
Why?Most broken releases break something old, not the new feature. Checking one old flow on every preview catches that before it reaches users.
When the preview passes your checklist, open the pull request on GitHub, click Merge pull request and confirm. Vercel builds
mainas a new Production deployment and points your address at it once it is ready.Then open the live site yourself and repeat the two most important checks: log in, open the Students page. If something is wrong, do not panic: Lesson 5 shows how to put the previous version back in one click.
Put in order Put the safe release flow in the right order
Tap the steps in the order you would do them. Tap a placed step to remove it.
- 1
Why?The merge is your "go live" button. Everything before it is free to break; everything after it is seen by users. Keeping that line clear is the whole habit.
You will meet other hosts in tutorials and client projects. The words differ, the idea is the same:
- Netlify makes a Deploy Preview for every pull request, with an address like
deploy-preview-42--yoursite.netlify.app. - Cloudflare Pages makes a preview for each branch and pull request, with a branch address like
fee-reminder.yourproject.pages.dev. - Cloudflare Workers has a newer Previews feature that gives each branch its own copy and link.
Match them Match each word with what it means
Tap an item on the left, then its meaning on the right.
Why?Once you know "branch = preview, main = production", you can use any host. Look for the host's preview feature on day one.
- Netlify makes a Deploy Preview for every pull request, with an address like
- Production comes from
main; previews come from every other branch and pull request. - Ask the agent to branch, build, commit and push; you open the pull request and click Visit Preview.
- Previews are private by default and use Preview settings, so test there on a phone with a test account.
- Merging the pull request is your go-live button; check the live site right after.
- Next: Environment variables for each environment, so previews use test data and production uses live data.
- Production comes from
Create a free account to save your progress and open every lesson. Create free account