Connect your GitHub repo to a live backend using Vercel or Railway — and understand what's actually happening.
Your frontend (HTML, React, etc.) runs in the user's browser. The backend runs on a server — it handles logic, talks to databases, authenticates users, and returns data. The browser never sees the backend code directly; it only sees responses.
A backend is just code that listens for requests. It could be a Node.js Express app, a Python FastAPI service, or a set of serverless functions. The platform (Vercel or Railway) is what runs that code and makes it reachable from the internet.
Both Vercel and Railway work the same fundamental way: you authorize them to read your GitHub repo, pick the repo, and they take it from there. Every push to main triggers a new deploy automatically.
Grant the platform OAuth access to your repos (you can scope it to specific repos only).
Select which repo to deploy and which branch is your production branch (usually main).
Add secrets (API keys, DB connection strings) as env vars in the dashboard — never in code.
The platform clones your repo, runs your build command, and starts serving traffic.
Vercel is built for frontend frameworks — Next.js especially (they created it). Its backend story is serverless functions: short-lived, stateless functions that spin up per request and disappear. No always-on server.
Drop a file in /api — Vercel turns it into an endpoint. No Express setup, no port config, no server to manage.
Railway runs your code as a persistent service inside a container. If you have an Express app, a FastAPI server, or a worker process, Railway runs it continuously — just like a real server, without you managing infrastructure.
Railway also provisions databases (Postgres, MySQL, Redis, MongoDB) as separate services in the same project. Your backend env var gets the connection string automatically — no copy-pasting credentials.
| Use Case | Platform | Why |
|---|---|---|
| Next.js full-stack app | Vercel | Designed for it. Zero config. |
| Standalone Express / FastAPI API | Railway | Needs a persistent server process. |
| Background job / queue worker | Railway | Vercel functions die after the request. |
| Websocket / real-time app | Railway | Needs persistent connections. |
| Simple CRUD API with Postgres | Either | Railway has it built in; Vercel + Neon is equally easy. |
| Static site + a few API endpoints | Vercel | Free tier, instant deploy, no overhead. |
| Scraper / long-running task | Railway | Functions time out; Railway doesn't. |
Neither platform stores secrets in your code — you set them in the dashboard and they're injected at runtime. Your .env file never leaves your machine.