Deployment: Launching to the World
Learning Objectives
- Understand the difference between local and deployed environments
- Learn basic Git and GitHub usage
- Deploy frontend with Vercel
- Deploy backend with Railway
- Connect a custom domain
6.1 What is Deployment?
Local vs Deployed
| Aspect | Local | Deployed |
|---|---|---|
| Address | localhost:3000 | linkhub.com |
| Access | Only your computer | Anyone worldwide |
| Execution | Computer must be on | 24/7 automatic |
| Data | Stored on your computer | Stored in the cloud |
Services We'll Use
- Vercel - Frontend deployment (free, Next.js optimized)
- Supabase - Database (already in use)
6.2 Git Basics
To deploy, you need to upload your code to GitHub. Git is a tool for managing code versions.
Git Basic Concepts
- Repository - Where the project is stored
- Commit - A unit for saving changes
- Push - Upload local commits to the remote
Uploading to GitHub
- Create a New Repository on GitHub.com
- In your terminal:
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/username/linkhub.git
git push -u origin mainTip
Ask Claude "How do I upload this project to GitHub?" and it will walk you through it step by step.
6.3 Frontend Deployment - Vercel
Step 1: Sign Up for Vercel
- Go to vercel.com
- Click "Continue with GitHub"
- Link your GitHub account
Step 2: Deploy Your Project
- Click "Add New..." → "Project"
- Select your GitHub repository
- Framework: Next.js auto-detected
- Set environment variables (important!)
- Click "Deploy"
Environment Variable Setup
Add the same variables from your local .env.local in Settings → Environment Variables:
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
NEXT_PUBLIC_APP_URL=https://linkhub.comAuto Deployment
Every time you push to GitHub, Vercel automatically deploys the new version. Just modify → commit → push!
6.4 Backend Deployment - Railway (Optional)
Use Railway when you need a custom API server or background jobs (cron jobs, image processing, etc.). LinkHub uses Supabase Realtime so a separate WebSocket server isn't needed, but you may need a backend server as your service grows.
Step 1: Sign Up for Railway
- Go to railway.app
- Sign up with GitHub
Step 2: Deploy Your Project
- "New Project" → "Deploy from GitHub repo"
- Select your server repository
- Set root directory (if the server folder is separate)
- Set environment variables
- Deployment complete!
Domain Setup
Generate a Railway domain via Settings → Networking → Generate Domain, or connect a Custom Domain.
6.5 Connecting a Custom Domain
Buying a Domain
Places to buy domains:
- Namecheap - Affordable .com domains
- Cloudflare - Cost-price sales, easy DNS management
- Google Domains - Simple interface
DNS Basics
| Record | Purpose | Example |
|---|---|---|
| A | Domain → IP address | linkhub.com → 123.45.67.89 |
| CNAME | Domain → Another domain | www → linkhub.com |
Using Subdomains
You can split subdomains by purpose:
- linkhub.com → Vercel (main app)
- www.linkhub.com (opens in a new tab) → Redirect to linkhub.com
6.6 Post-Deployment Checklist
Required Checks
- All pages accessible
- Login/logout working properly
- DB connection working (data save/retrieve)
- WebSocket connection working
- No missing environment variables
- HTTPS confirmed (lock icon)
- Works on mobile too
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Page not loading | Missing env vars | Check environment variables in Vercel |
| API errors | Wrong backend URL | Check NEXT_PUBLIC_SOCKET_URL |
| Can't login | Redirect URL error | Check Supabase Auth settings |
| DB connection failed | RLS policy issue | Check Supabase policies |
6.7 Checking Logs
The ability to check logs when errors occur is a key skill for solving problems on your own.
Vercel Logs
- Vercel Dashboard → Select project
- Deployments tab → Click recent deployment
- Check real-time logs in the Functions tab
- Errors are shown in red
Railway Logs
- Railway Dashboard → Select project
- Click service → Logs tab
- View real-time log streaming
- Filter specific errors with search
Reading Logs
| Log Type | Meaning | Action |
|---|---|---|
| INFO | Normal operation record | Can ignore |
| WARN | Warning (still works) | Check later |
| ERROR | Error occurred | Check immediately |
| 500 Internal Server Error | Server code issue | Check code |
| 404 Not Found | Path doesn't exist | Check URL, routing |
| 401/403 | Auth/permission issue | Check token, permissions |
Ask AI About Logs
Copy the entire error log and ask Claude "Analyze this error log and tell me the solution" - most issues get resolved this way. It's perfectly fine if you can't read logs yourself!
6.8 Deployment Troubleshooting
CORS / Origin Issues
CORS errors occur when frontend and backend domains are different.
// Express server
import cors from 'cors';
app.use(cors({
origin: ['https://linkhub.com', 'https://www.linkhub.com'],
credentials: true,
}));Railway WebSocket Timeout
Railway has a default 60-second timeout. WebSocket requires keepalive settings.
// Client side
const socket = io(SERVER_URL, {
pingInterval: 25000,
pingTimeout: 60000,
});6.9 Operations and Monitoring
Error Tracking: Sentry
Collect frontend and backend errors in real-time.
npm install @sentry/nextjsKey Metrics Monitoring
| Metric | Meaning | Normal Range |
|---|---|---|
| Active users | DAU/MAU | Check growth trend |
| Page load time | Profile page response speed | < 2 seconds |
| Click rate | Link clicks / page views | Service engagement |
| Error rate | 500 error ratio | < 1% |
6.10 Other Deployment Options
Besides Vercel and Railway, there are various deployment platforms available.
Frontend Deployment Options
| Service | Features | Free Tier | Recommended For |
|---|---|---|---|
| Vercel | Next.js optimized | 100GB/month | When using Next.js (recommended) |
| Netlify | JAMstack specialized | 100GB/month | Static sites, when Forms needed |
| Cloudflare Pages | Edge deployment, fast | Unlimited | When global speed matters |
| AWS Amplify | AWS ecosystem | Free tier | AWS service integration |
| GitHub Pages | Completely free | Unlimited | Simple static sites |
Backend Deployment Options
| Service | Features | Free Tier | Recommended For |
|---|---|---|---|
| Railway | Easy setup, WebSocket support | $5/month credit | Quick deployment |
| Render | Simple, auto-scaling | 750 hours/month | Railway alternative |
| Fly.io | Edge deployment, Docker-based | 3 shared VMs | When global deployment needed |
| Coolify | Self-hosted PaaS | Free (own server) | When full control wanted |
| DigitalOcean App Platform | Stable, predictable costs | $0 (static) | When budget management important |
Netlify (Frontend)
Strong for static sites and serverless functions.
Deploy Next.js project to Netlify.
Include netlify.toml config file.# netlify.toml
[build]
command = "npm run build"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"Cloudflare Pages (Frontend)
Served from edge locations worldwide, extremely fast.
Deploy Next.js project to Cloudflare Pages.
Use @cloudflare/next-on-pages.Cloudflare Advantages
- Unlimited bandwidth
- Global edge deployment
- DDoS protection included
- Run serverless functions with Workers
Render (Backend)
Similar to Railway but often rated as more stable.
Deploy Node.js WebSocket server to Render.
Include render.yaml config file.# render.yaml
services:
- type: web
name: linkhub-server
env: node
buildCommand: npm install && npm run build
startCommand: npm start
envVars:
- key: NODE_ENV
value: productionFly.io (Backend)
Deploy Docker containers to edge locations worldwide.
Deploy Node.js server to Fly.io.
Include Dockerfile and fly.toml config.# fly.toml
app = "linkhub-server"
primary_region = "nrt" # Tokyo
[http_service]
internal_port = 3000
force_https = trueCoolify (Self-hosted)
Build a Vercel/Railway-like environment on your own server.
Install Coolify on my server.
Then deploy the LinkHub project.All-in-One Options
| Service | Features | Price |
|---|---|---|
| Supabase | DB + Auth + Storage + Edge Functions | Free~$25/month |
| Firebase | Google all-in-one | Free~usage-based |
| Convex | DB + Real-time + Serverless | Free~$25/month |
Which One Should You Choose?
| Situation | Frontend | Backend |
|---|---|---|
| Easiest start | Vercel | Railway |
| Minimize costs | Cloudflare Pages | Render (free tier) |
| Global speed | Cloudflare Pages | Fly.io |
| AWS ecosystem | Amplify | AWS Lambda |
| Full control | Coolify | Coolify |
Vibe Coding Tip
Deployment platforms are relatively easy to switch later. Start with Vercel + Railway, then optimize as traffic grows.
Chapter Summary
- Learned Git and GitHub basics
- Deployed frontend with Vercel
- Deployed backend with Railway
- Connected a custom domain
- Completed post-deployment checks
- Learned how to check logs
- Explored various deployment options
In the next chapter, we'll add payments to start generating revenue!