Node.js
A runtime that runs JavaScript outside the browser, on servers and developer machines, built to handle many requests at once.
- Type
- JavaScript runtime
- Created by
- Ryan Dahl in 2009, now under the OpenJS Foundation (MIT license)
- Engine
- V8, the JavaScript engine from Chrome
- In my stack
- Next.js servers, integrations, scripts and tooling
What it is
Node.js takes the JavaScript engine from Chrome and lets it run on a server. Its model is non-blocking: while it waits for a database, a file or another API, it keeps serving other requests instead of sitting idle. That makes it efficient for web servers and APIs that spend most of their time waiting on input and output.
It comes with npm, the largest package registry in the world, and with built-in modules for HTTP, files, cryptography, streams and testing. Nearly all frontend tooling runs on it: the build tools behind React, React Native and Next.js are Node.js programs, and so is the Next.js server itself.
Why I use it
One language across the stack. The same JavaScript or TypeScript, and often the same types and validation, on the frontend and on the server.
Great for integrations. Nearly every SaaS, payment provider and email service publishes a Node.js SDK first, so connecting systems is quick.
Fast to build with. For webhooks, small services and scripts, a few dozen lines are enough, with a package for almost any need.
It runs everywhere. Containers, serverless functions, Vercel, edge runtimes: there is no shortage of deployment options.
Where I use it
Node.js runs the server side of Next.js apps and all the JavaScript tooling behind my React and React Native work. I also use it for integration services and webhooks that talk to third-party APIs, for one-off data migrations and import scripts, and for backends that are mostly glue between other services. For core business APIs that must be fast and long-lived, I usually pick Go.
Best use cases
- Servers for Next.js and other web frameworks.
- Integrations and webhooks with payment, email, CRM and other third-party services.
- Real-time features with WebSockets, such as notifications or live updates.
- Scripts and tooling: data imports, migrations, build tools and automation.
When I’d use something else
For CPU-heavy work like image processing or large calculations, Node.js’s single main thread becomes a limit, and Go or a specialised service does better. For large, long-lived business APIs, I prefer Go’s simple deployment and small dependency tree, since the size of the npm ecosystem also means more third-party code to audit.
A small example
A small webhook receiver using only Node’s built-in modules. It refuses any event that isn’t signed with the shared secret.
import { createServer } from "node:http";
import { createHmac, timingSafeEqual } from "node:crypto";
const secret = process.env.WEBHOOK_SECRET;
createServer(async (req, res) => {
let body = "";
for await (const chunk of req) body += chunk;
// Only accept events signed with our shared secret
const expected = createHmac("sha256", secret).update(body).digest("hex");
const received = String(req.headers["x-signature"] ?? "");
const valid =
received.length === expected.length &&
timingSafeEqual(Buffer.from(received), Buffer.from(expected));
if (!valid) {
res.writeHead(401).end();
return;
}
const event = JSON.parse(body);
console.log("received", event.type);
res.writeHead(204).end();
}).listen(3000);