Node.js
Node.js is a cross-platform JavaScript runtime that allows running JavaScript outside the browser on the server.
Node.js revolutionized web development by bringing JavaScript from the browser to the server. Developers can use one language for both frontend and backend. Thanks to its event-driven, non-blocking architecture Node.js is especially suited to I/O-heavy applications like APIs, real-time apps and microservices. Companies like LinkedIn, PayPal and Uber use Node.js in production.
What is Node.js?
Node.js is an open-source runtime built on Google’s V8 JavaScript engine that runs JavaScript outside the browser. The core concept is the event loop: a single thread handles requests non-blocking by delegating I/O (database, file system, network) to the OS. When an operation completes, a callback runs. This model lets Node.js handle thousands of concurrent connections with minimal resources. npm is the world’s largest package registry with over two million packages. Node.js supports both CommonJS and ES modules and has built-in support for HTTP, streams, file system and crypto.
How does Node.js work?
When a request arrives it is handed to the event loop. Instead of a new thread per request, Node.js processes all requests in one thread. I/O operations like database queries run asynchronously: Node.js registers a callback and continues with the next request. When I/O finishes the callback is queued and run when possible. For CPU-heavy work, worker threads allow parallel execution. Modern Node.js apps use async/await for readable asynchronous code.
Practical Examples
REST API with Express: An Express server exposes CRUD endpoints for a web app and talks to a PostgreSQL database.
Real-time chat: Socket.io on Node.js enables bidirectional real-time communication for thousands of concurrent users.
CLI tools: npm packages like ESLint, Webpack and Prettier are written in Node.js and used by millions daily.
Microservice backend: Individual microservices with Fastify or NestJS handle specific business logic and communicate via message queues.
Streaming server: Node.js streams process large files (video, CSV imports) in chunks without loading everything into memory.
Typical Use Cases
RESTful APIs: Lightweight, fast APIs with Express, Fastify or NestJS for web and mobile
Real-time apps: Chat, live dashboards and collaboration tools with WebSocket support
Server-side rendering: Frameworks like Next.js use Node.js to render React on the server
Build tools and CLIs: Webpack, Vite, ESLint and many dev tools are built on Node.js
IoT backend: Processing sensor data in real time thanks to non-blocking I/O
Advantages and Disadvantages
Advantages
- One language for everything: JavaScript on frontend and backend reduces context switching and enables code sharing
- High concurrency: Non-blocking architecture handles thousands of concurrent connections efficiently
- Huge ecosystem: npm has over two million packages for almost any use case
- Fast development: Hot reload, simple setup and many frameworks speed up development
- Strong community: Large, active community with extensive documentation
Disadvantages
- Single-threaded: CPU-heavy work blocks the event loop and affects all requests
- Callback complexity: Despite async/await, error handling in async code can get complex
- Dependency risk: Reliance on many npm packages brings security and stability risks
- Not ideal for compute-heavy tasks: For image processing, ML or heavy number crunching, Python or Go are better
Frequently Asked Questions about Node.js
Is Node.js a framework or a programming language?
When should I choose Node.js over Python or Java for the backend?
Can Node.js be used for large enterprise applications?
Related Terms
Want to use Node.js in your project?
We are happy to advise you on Node.js and find the optimal solution for your requirements. Benefit from our experience across over 200 projects.