Getting Started with Node.js for Backend JavaScript

Node.js took JavaScript out of the browser and put it on the server, using the same V8 engine that powers Chrome — a huge shift for a language that was originally designed exclusively for client-side scripting.

import http from 'node:http';

const server = http.createServer((req, res) => {
    if (req.url === '/api/health') {
        res.writeHead(200, { 'Content-Type': 'application/json' });
        res.end(JSON.stringify({ status: 'ok' }));
        return;
    }
    res.writeHead(404);
    res.end('Not found');
});

server.listen(3000, () => console.log('Listening on :3000'));

Why It Matters

Node’s non-blocking, event-driven I/O model (the same event loop concept from browser JavaScript) makes it genuinely good at handling many concurrent connections with relatively low overhead — a natural fit for APIs, real-time apps, and I/O-heavy services, though not ideal for CPU-bound heavy computation.

node server.js
# or with auto-restart on file changes during development
node --watch server.js