Why Vercel beats GitHub Pages for real products
GitHub Pages is great for static HTML/CSS/JS sites — and it still is for those. But when your product uses a build step (React, Next.js), environment variables, or serverless functions, you need something more capable.
-
Automatic deploys — push to GitHub → Vercel builds and deploys in under 30 seconds. No manual steps.
-
Preview deployments — every pull request gets its own live URL. Share it for review before merging.
-
Environment variables — store API keys and secrets securely. They never appear in your code or GitHub.
-
Serverless functions — write backend logic (like making API calls with secret keys) without maintaining a server.
-
Custom domains — connect a domain in 2 minutes. Free SSL included.
Deploying to Vercel
-
1Push your project to GitHub (you know how to do this from Chapter 5).
-
2Go to vercel.com → Sign up with GitHub → "New Project" → Import your GitHub repo.
-
3Vercel auto-detects your framework (React, Next.js, plain HTML, etc.) and sets the build command. Click Deploy.
-
4In 30 seconds you have a live URL:
your-project.vercel.app. Share it. Every future push tomaintriggers a new deploy automatically.
Environment variables — keeping secrets secret
API keys, database passwords, and secret tokens must NEVER go in your code. If they end up in your GitHub repository, they're public. Environment variables solve this — they're stored in Vercel (or locally in a .env file) and injected into your code at build time.
# .env.local
ANTHROPIC_API_KEY=sk-ant-api03-...
FIREBASE_API_KEY=AIzaSy...
DATABASE_URL=postgres://user:password@host/db
// In a Next.js API route or Vercel serverless function
const apiKey = process.env.ANTHROPIC_API_KEY;
// In client-side React (Vite), prefix with VITE_
// Note: client-side env vars are public — only use for non-secret values
const publicKey = import.meta.env.VITE_PUBLIC_KEY;
Serverless functions
A serverless function is a small piece of backend code that runs on-demand. In Vercel, you create a file in the /api folder and it becomes an API endpoint — no server setup, no always-running process, no infrastructure to maintain.
// This file lives at /api/chat.js
// Vercel automatically makes it available at /api/chat
// The API key stays on the server — never exposed to browsers
export default async function handler(req, res) {
const { message } = req.body;
const response = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'x-api-key': process.env.ANTHROPIC_API_KEY, // secret, server-only
'content-type': 'application/json',
},
body: JSON.stringify({
model: 'claude-opus-4-6',
max_tokens: 1024,
messages: [{ role: 'user', content: message }]
})
});
const data = await response.json();
res.json({ reply: data.content[0].text });
}
-
1Take the ideas board HTML file from Chapter 14. Create a new GitHub repo for it and push the file.
-
2Import the repo to Vercel. Deploy it. You now have a public URL for your app.
-
3In Firebase console, add your new Vercel domain to the authorized domains list (Authentication → Settings → Authorized domains → Add domain). This is required for Google sign-in to work on your production URL.
-
4Bonus: Buy a domain from Namecheap or Google Domains (~$10/yr). Add it to your Vercel project. In 2 minutes you have a professional domain. Share it with someone outside your network and ask them to try it.
- Vercel = push to GitHub → instant production deploy. Zero-config for most frameworks
- Environment variables store secrets safely. Never put API keys in code that goes to GitHub
- Serverless functions (in
/api) let you write backend logic without managing a server - Every push to
mainauto-deploys. Every pull request gets a preview URL for review - Custom domains take 2 minutes to configure. SSL is automatic and free