Discover the Magic of Node.js

Learning web development in public. Writing simple, real-world explanations about web development concepts. Helping beginners understand why things work, not just how.
Search for a command to run...

Learning web development in public. Writing simple, real-world explanations about web development concepts. Helping beginners understand why things work, not just how.
No comments yet. Be the first to comment.
Every day, millions of users upload photos, videos, stories, and reels to Instagram. From a user's perspective, the process appears simple: select media, apply filters, add a caption, and tap "Post."
Building Offline-First Messaging Apps: How Messages Work Without Internet Modern messaging applications have transformed the way people communicate. Whether it's chatting with friends, collaborating w
In this article we'll explore about the Expo Router and React Navigation and answer which one to use in 2026. If you build mobile apps using React Native, one thing becomes obvious very quickly: Navig

Modern mobile apps are no longer just a collection of screens connected together. Apps like Instagram, WhatsApp, Uber, and Netflix operate at massive scale with millions of users, real time systems, o
In this article we'll be exploring react.js and the things of react.js that makes it popular and stand out among other libraries ( no fight over library vs framework ). We'll go through: What problem

Shkaai
68 posts
Node.js is an open-source and cross-platform JavaScript runtime environment. Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser.
Built on:
Chrome’s V8 JavaScript Engine
Uses libuv for handling asynchronous I/O operations
V8 is the name of the JavaScript engine that powers Google Chrome. It's the thing that takes our JavaScript and executes it while browsing with Chrome. V8 is written in C++, and it's continuously improved. It is portable and runs on Mac, Windows, Linux and several other systems.
V8 is the JavaScript engine i.e. it parses and executes JavaScript code. The DOM, and the other Web Platform APIs (they all makeup runtime environment) are provided by the browser.
Other browsers have their own JavaScript engine:
Firefox has SpiderMonkey
Safari has JavaScriptCore (also called Nitro)
Edge was originally based on Chakra but has more recently been rebuilt using Chromium and the V8 engine.
and many others exist as well.
libuv is a C-based library that provides asynchronous I/O in Node.js.
It’s the engine behind Node’s non-blocking I/O model.
Node.js uses libuv to handle:
File system operations (e.g., fs.readFile)
Networking (HTTP, TCP)
Timers (setTimeout)
Child processes
DNS
libuv provides a thread pool and event loop that handles these tasks in the background, while your main JS thread keeps executing code.
Here's a breakdown of how libuv works inside Node.js:
Core part of Node.js
Keeps checking: “Is there something to do?”
Runs your callbacks once async work is done
For heavy/slow tasks like:
File reading/writing
DNS lookups
Default: 4 threads (can be changed via UV_THREADPOOL_SIZE)
Monitors sockets, file descriptors using system APIs (like epoll, kqueue, or IOCP)
These don’t need threads — they're non-blocking by nature
Imagine you're a project manager (Node.js event loop).
You handle multiple clients (incoming tasks) and coordinate work.
For simple, fast tasks (like taking orders), you do them directly.
For big tasks (like building a house), you assign workers (libuv threads).
While they work, you keep managing other incoming tasks.
When a worker is done, they notify you (callback), and you deliver the result to the client.
Your team (libuv) makes you look like a multitasking genius, even though you're single-threaded.
const fs = require('fs');
console.log('Start');
fs.readFile('data.txt', 'utf8', (err, data) => {
console.log('File read complete:', data);
});
console.log('End');
Behind the scenes:
JS thread reaches fs.readFile call.
Instead of blocking, it hands the task to libuv.
libuv uses thread pool to read file.
JS thread continues — prints “End”.
Once the file is read, libuv signals the event loop.
Event loop queues the callback → prints file content.
Simplified Flow Diagram┌─────────────────────────────┐
│ JS Main Thread │
└────────────┬────────────────┘
↓
[Call to fs.readFile]
↓
┌────────────▼────────────┐
│ libuv │
│ ┌─────────────────────┐ │
│ │ Thread Pool │ │◄───── For CPU/I/O tasks
│ └─────────────────────┘ │
│ ┌─────────────────────┐ │
│ │ I/O Polling │ │◄───── For sockets, timers
│ └─────────────────────┘ │
└────────────┬────────────┘
↓
[Callback ready]
↓
Event Loop triggers
↓
[JS Callback executes]
Node.js is single-threaded in JavaScript, but libuv runs a multi-threaded party behind the scenes!
This is how Node handles lots of concurrent I/O without being blocked.