Summary
Deploy your vibe‑coded AI website or app (Next.js/React/static) to Vercel using GitHub so every push triggers an automatic build and deployment. You’ll set up preview deployments for every pull request, connect environment variables safely, add a custom domain, and verify CI/CD works end‑to‑end—without running servers.
Introduction: What you’ll build or accomplish
Do this to turn your “vibe‑coded” designs—rapid prototypes generated or assisted by AI tools—into a production-ready website that deploys automatically from GitHub. You will:
- Push your project to GitHub
- Import it into Vercel
- Enable automatic deployments (CI/CD) on every commit
- Create Preview Deployments for every pull request
- Configure environment variables for AI keys safely
- Attach a custom domain and verify SSL
Why this matters for AI learners: AI projects often change fast. You want a deployment workflow that is frictionless, repeatable, and safe with secrets. Vercel + GitHub gives you that by default: one repo, one pipeline, continuous previews, and production releases with minimal configuration.
Why use Vercel for hosting vibe‑coded designs and AI apps?
1) Ship faster with built-in CI/CD
Do this because you should not manually upload files or run servers when you’re iterating quickly. Vercel automatically builds and deploys when GitHub changes. That means:
- Push to a branch → get a live preview URL
- Merge to main → Vercel promotes to production
Why: You reduce human error and remove deployment as a bottleneck.
2) Preview Deployments make collaboration easy
Each pull request can get its own deploy. Share that URL with teammates, clients, or your future self.
Why: You validate UI/UX and AI flows before merging. This is ideal for vibe-coded designs where visuals change often.
3) Great defaults for modern frontends
Vercel is optimized for common web stacks such as Next.js, React, and static sites. It also supports serverless functions and edge runtimes depending on your framework and plan.
Why: Most AI-driven web demos are frontend-heavy and benefit from fast global delivery.
4) Safe secret management for AI keys
You can store API keys (OpenAI, Anthropic, etc.) as environment variables in Vercel instead of committing them to GitHub.
Why: Committed secrets get leaked, rotated, and abused. Vercel env vars keep secrets out of your repo.
Prerequisites: Required tools, knowledge, or setup
- A GitHub account
- A Vercel account (free tier works for many demos)
- Node.js LTS installed (recommended) for local testing
- Git installed
- A project to deploy (example below uses Next.js, but steps apply to most frameworks)
Recommended local checks
Run these commands to ensure your environment is ready:
node -v
npm -v
git --versionExpected output: You should see version numbers for each command (for example, Node 18+ or 20+).
Step 1: Create (or choose) a vibe‑coded project that deploys cleanly
Do this first because CI/CD will repeatedly install dependencies and build your project. If your build is flaky locally, it will be flaky on Vercel.
Option A: Use an existing project
If you already have a repo from an AI code generator or a design-to-code workflow, keep it. Just make sure it builds.
Option B: Create a simple Next.js app (recommended for AI demos)
npx create-next-app@latest vibecoded-vercel-demo
cd vibecoded-vercel-demo
npm run devExpected result: Your terminal shows a local URL (usually http://localhost:3000). Open it and confirm the homepage loads.
Screenshot description
Screenshot: Browser window showing the default Next.js landing page running on localhost:3000.
Step 2: Initialize Git and push your project to GitHub
Do this because Vercel’s easiest CI/CD path is “import from GitHub.” No manual zip uploads, no FTP, no server access.
2.1 Initialize a local repo
git init
git add .
git commit -m "Initial commit"Expected result: Git creates a commit. If you run git log --oneline, you should see your commit message.
2.2 Create a GitHub repository
Do this in GitHub:
- Click New repository
- Name it (example:
vibecoded-vercel-demo) - Choose Public or Private
- Do not initialize with a README if you already have local files
2.3 Push your local repo to GitHub
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/vibecoded-vercel-demo.git
git push -u origin mainExpected result: Your code appears in GitHub under the main branch.
Warning (destructive): If you accidentally push secrets (API keys) to GitHub, assume they are compromised. Rotate them immediately. Do not rely on deleting the commit as a fix.
Step 3: Import the GitHub repo into Vercel (the easiest CI/CD setup)
Do this because Vercel will automatically create a pipeline: it checks out your repo, installs dependencies, builds, and deploys—every time GitHub changes.
3.1 Connect Vercel to GitHub
- Log into Vercel
- Go to Add New… → Project
- Choose Import Git Repository
- Authorize GitHub access when prompted
Expected result: You can see a list of your GitHub repositories from within Vercel.
3.2 Import the repo
- Select your repo (example:
vibecoded-vercel-demo) - Click Import
3.3 Confirm framework settings
Vercel usually auto-detects Next.js. Verify:
- Framework Preset: Next.js (or your framework)
- Build Command: typically
next build(often vianpm run build) - Output Directory: usually auto-managed for Next.js
Why: Incorrect build commands are the #1 reason first deployments fail.
3.4 Deploy
Click Deploy.
Expected result: Vercel builds your app and gives you a live URL like:
https://vibecoded-vercel-demo.vercel.app
Screenshot description
Screenshot: Vercel “Deployments” page showing a green “Ready” status with a preview URL.
Step 4: Understand Vercel’s Git-based CI/CD workflow (what happens automatically)
Do this because you need to predict how changes move from local → GitHub → preview → production.
4.1 Preview deployments (Pull Requests)
When you open a pull request, Vercel can automatically build a Preview Deployment for that branch.
Why: You can review vibe-coded UI changes safely without affecting production.
4.2 Production deployments (main branch)
When you merge the pull request into main, Vercel automatically builds and deploys to production.
Why: Your production site always matches the exact commit in main. This is the core CI/CD promise.
4.3 Rollbacks (practical safety)
Vercel keeps prior deployments. If a vibe-coded change breaks the site, you can redeploy an older working version.
Why: AI-assisted code can introduce regressions quickly; rollback is your safety net.
Step 5: Add environment variables safely (for AI keys and config)
Do this because most AI apps need secrets (API keys). Never hardcode them in your repo.
5.1 Add env vars in Vercel
- In Vercel, open your project
- Go to Settings → Environment Variables
- Add variables (examples):
OPENAI_API_KEY=your_key_here
NEXT_PUBLIC_APP_NAME=VibeCoded DemoWhy: Vercel injects these at build/runtime (depending on framework). Your GitHub repo stays clean.
Warning (destructive): If you mark a secret as NEXT_PUBLIC_* in Next.js, it becomes available in client-side JavaScript and can be viewed by anyone. Do not put API keys in NEXT_PUBLIC_ variables.
5.2 Update your code to read env vars
Example: server-side usage in a Next.js route handler:
// app/api/health/route.js
export async function GET() {
const hasKey = Boolean(process.env.OPENAI_API_KEY);
return Response.json({ ok: true, hasOpenAIKey: hasKey });
}Expected result: Visiting /api/health returns JSON showing whether the key exists.
5.3 Trigger a redeploy
Do this because changing env vars may require a rebuild to apply.
- Option A: Push a commit (recommended)
- Option B: Use Vercel’s “Redeploy” button for the latest deployment
Step 6: Prove CI/CD works by shipping a change via branch + PR
Do this because you should verify the pipeline now—before you rely on it for demos, portfolio launches, or client work.
6.1 Create a feature branch
git checkout -b feature/update-homepage6.2 Make a small UI change
Edit your homepage file (example: app/page.js or pages/index.js). Add a visible banner:
export default function Home() {
return (
<main style={{ padding: 24, fontFamily: 'system-ui' }}>
<h1>Vibe-coded demo on Vercel</h1>
<p>This page was deployed automatically from GitHub.</p>
</main>
);
}6.3 Commit and push
git add .
git commit -m "Update homepage banner"
git push -u origin feature/update-homepageExpected result: GitHub shows the new branch. Vercel begins building a Preview Deployment automatically.
6.4 Open a pull request
In GitHub:
- Click Compare & pull request
- Create the PR into
main
Expected result: The PR gets a Vercel status check and a Preview URL (often shown in the PR checks or comments).
Screenshot description
Screenshot: GitHub Pull Request page with a “Vercel — Preview” check and a clickable deployment link.
6.5 Merge the PR to deploy to production
Merge the pull request.
Expected result: Vercel triggers a Production Deployment for main. Your production URL updates with the new banner.
Step 7: Add a custom domain (optional but recommended)
Do this because a custom domain increases trust and makes your AI project easier to share and remember.
7.1 Attach the domain in Vercel
- Go to Project → Settings → Domains
- Add
yourdomain.com(and optionallywww.yourdomain.com)
7.2 Update DNS records
Vercel will show required DNS changes. Common patterns:
- A record for apex domain pointing to Vercel IP (Vercel provides the value)
- CNAME record for
wwwpointing tocname.vercel-dns.com
Why: DNS tells the internet where your site lives.
Expected result: After DNS propagates (minutes to hours), Vercel verifies the domain and issues SSL automatically.
Step 8: Use the Vercel CLI for power-user workflows (optional)
Do this because sometimes you want quick previews without opening the dashboard, or you want to link projects and pull env vars locally.
8.1 Install the CLI
npm i -g vercel8.2 Log in
vercel loginExpected result: Your browser opens for authentication.
8.3 Deploy from your machine (creates a preview)
vercelExpected result: The CLI prints a Preview URL when the upload/build finishes.
8.4 Promote to production (be careful)
vercel --prodWarning (potentially destructive): This updates production immediately. Prefer GitHub merges for production so deployments remain traceable and reviewable.
Expected results (checkpoints)
- After Step 3: A live
.vercel.appURL loads your site - After Step 5: Your
/api/healthendpoint reports env vars correctly - After Step 6: PRs generate Preview Deployments and merges update production
- After Step 7: Your custom domain loads over HTTPS with a valid certificate
Troubleshooting: Common issues and solutions
Issue 1: Build fails on Vercel but works locally
Why it happens: Different Node versions, missing lockfile, or environment differences.
Fix it:
- Commit your lockfile (
package-lock.json,pnpm-lock.yaml, oryarn.lock) - Set Node version if needed (Vercel project settings) or add
enginesinpackage.json:
{
"engines": {
"node": ">=18"
}
}Expected result: Deployment uses a compatible runtime and succeeds.
Issue 2: “Environment variable is undefined” in production
Why it happens: You added env vars locally but not in Vercel (or you added them to Preview but not Production).
Fix it:
- Go to Settings → Environment Variables
- Ensure variables exist for Production (and Preview if needed)
- Redeploy
Issue 3: You accidentally exposed an API key in client code
Why it happens: You used NEXT_PUBLIC_ prefix or called the AI API directly from the browser.
Fix it:
- Move AI calls to a server route (API route / route handler)
- Rotate the key immediately
Expected result: Secrets remain server-side and are not visible in DevTools.
Issue 4: Vercel doesn’t create preview deployments for PRs
Why it happens: Repo permissions, Git integration not installed for the org, or disabled settings.
Fix it:
- Check Vercel Git integration permissions
- Ensure the project is connected to the correct repo
- Verify your PR is from a branch in the same repo (fork PRs may behave differently depending on settings)
Issue 5: 404 on routes after deployment (single-page apps)
Why it happens: Your framework needs rewrite rules for client-side routing.
Fix it: Add a Vercel configuration file (vercel.json) if your framework requires it, or use the correct adapter/preset. Example for many SPA setups:
{
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
}Warning: Rewrites can break API routes if misconfigured. Test carefully.
Testing: Verify everything works end-to-end
1) Test the production URL
Open your production domain or .vercel.app URL in an incognito window.
Expected result: Page loads, styling renders, and there are no console errors.
2) Test Preview Deployments
Open a new PR with a tiny change and confirm a preview URL appears.
Expected result: Preview URL shows the change; production does not.
3) Test your API health endpoint
Open:
https://YOUR_DOMAIN/api/healthExpected result: JSON response similar to:
{ "ok": true, "hasOpenAIKey": true }4) Confirm no secrets are in GitHub
Search your repo for key patterns:
git grep -n "OPENAI_API_KEY"
git grep -n "sk-"Expected result: No matches for secrets.
Next Steps: Extend and improve your Vercel + GitHub setup
1) Add a staging environment using a branch
Do this by setting a dedicated staging branch and treating it as a near-production preview.
Why: You can test AI model changes and UI iterations with realistic settings before merging to main.
2) Add GitHub Actions for extra checks (lint, tests)
Vercel already builds, but you can fail PRs earlier by running unit tests and linting in GitHub Actions.
Example workflow file: .github/workflows/ci.yml
name: CI
on:
pull_request:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run lint --if-present
- run: npm test --if-presentExpected result: PRs show a CI status. If tests fail, you fix issues before Vercel ships broken builds.
3) Put AI calls behind server endpoints
Do this to protect keys and control costs.
Why: Client-side calls expose keys and invite abuse.
4) Monitor deployments and logs
Use Vercel’s deployment details and runtime logs to debug AI endpoints.
Why: When an AI API errors (quota, invalid key, timeout), logs show the real cause quickly.
Conclusion: What you learned and what to do next
You set up a clean, modern hosting workflow for vibe‑coded AI websites using Vercel + GitHub. You connected a repository, deployed automatically, generated preview builds for PRs, and secured secrets with environment variables. This is the practical CI/CD foundation you need for fast AI prototyping: ship quickly, review safely, and deploy reliably.
Now do this: add one AI feature behind a server route (chat, summarizer, or image captioning), store your API key in Vercel env vars, and use PR previews to iterate on UI and prompts without breaking production.

