May 4, 2025 •
Hey friends 👋,
If you're a web developer like me - working with React, Node, or the MERN stack - you've probably come across words like "serverless" and "edge runtime." At first, these terms confused me too, so I decided to dig in and write this simple explanation.
Whenever someone visits your website or hits your API, a computer somewhere (called a server) handles that request and sends back a response.
In the traditional way of building backends, we:
It's powerful, but takes time and energy.
Now here's the twist:
Serverless means you don't manage servers yourself. You just write small functions, and a cloud platform runs them for you — only when they're needed.
It's like magic. You write a function like:
export default function handler(req, res) {
res.json({ message: "Hello World" });
}
And platforms like Vercel, Netlify, or Cloudflare Workers take care of running it on-demand. You don't pay for idle time, and it scales automatically.
Let's say you want to build:
GET /api/hello → returns "Hello from my app"
Instead of creating a full Express server, you can write just this one function and deploy it as a serverless function.
export default function handler(req, res) {
res.json({ message: "Hello from my app" });
}
Then, you deploy it to a serverless platform like Vercel or Netlify. They handle everything for you.
Done. No backend boilerplate, no server setup. It's fast and clean.
This is where things get even cooler.
Edge Runtime means your serverless functions run from locations closest to the user — not from a single centralized server.
Cloud platforms have data centers all around the world. With edge runtime, your code runs in whichever location is closest to the person visiting your site.
Faster response time = better user experience.
Some platforms that support edge runtime:
These are amazing if you want to build fast, global APIs, authentication handlers, redirects, or even entire websites.
While edge functions are amazing, they do have some limits:
Still, for most lightweight APIs, auth, caching, and middleware logic - they're perfect.