Backend
Node.js
A server-side JavaScript runtime built on the V8 engine with an event-driven, non-blocking I/O model.
What it is
Node.js runs JavaScript outside the browser. Under the hood sits Chrome's V8 engine and the libuv library, which handles networking, files and timers through an event loop.
Your code runs on one thread, but I/O does not block it: while one request waits for the database, the event loop serves others. For heavy computation there are worker_threads and separate processes.
The npm ecosystem is the largest of any language. That made Node.js the base for APIs, BFFs, build tools (Vite, webpack) and server-side rendering.
Use it when
- I/O-heavy services: REST and GraphQL APIs, chats, streaming, websockets.
- The team already writes JavaScript or TypeScript and wants one language on front and back.
- You need build tooling, CLI utilities or a BFF for a frontend.
Avoid it when
- Long CPU-bound jobs (video processing, ML) on the main thread: they block the event loop.
- You need strict static typing without extra tooling: use TypeScript or another language.
Key concepts
- Event loop
- A loop that takes ready callbacks from queues and runs them one at a time on the main thread.
- libuv
- The C library for async I/O and the thread pool underneath Node.
- Streams
- Processing data in chunks without loading the whole file into memory.
- npm / ESM
- The package manager and the modern
import/exportmodule system.
Example
Interview questions
1. What is the event loop?
It is the mechanism that takes finished async operations from queues and runs their callbacks on one thread. It lets Node serve thousands of connections without a thread per connection.
2. Why should you not block the main thread?
While synchronous code runs, the event loop is stuck and every other request waits. Heavy computation moves to worker threads or a separate service.
3. How does
process.nextTickdiffer fromsetImmediate?nextTickruns right after the current operation, before the loop moves on, whilesetImmediateruns in the check phase after I/O. Too manynextTickcalls can starve the loop.
Related technologies
- DenoA secure JavaScript and TypeScript runtime from the creator of Node.js, with built-in tooling.
- BunA fast JavaScript and TypeScript runtime that bundles a runtime, package manager, bundler and test runner.
- ExpressA minimalist web framework for Node.js with routing and a middleware chain.
- NestJSA progressive TypeScript Node.js framework with modules, decorators and dependency injection.
- FastifyA fast Node.js framework with a plugin architecture and JSON Schema validation.
- TypeScriptA superset of JavaScript with static types that compiles to plain JS.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).