IT Career Guide
Search

Is Node js a Framework? Runtime vs Framework Explained

JavaScript code in a code editor

No, Node.js is not a framework: it is a JavaScript runtime environment that lets you run JavaScript outside the browser, mostly on servers. Node.js gives you the engine and the built-in modules to read files, open network connections and handle requests. Frameworks such as Express, NestJS and Fastify are built on top of Node.js to give your code a structure. So when someone asks whether Node.js is a framework, the accurate reply is that it is the platform that frameworks run on.

Key takeaways

  • Node.js is a runtime environment built on Google’s V8 JavaScript engine, not a framework or a library.
  • Express, NestJS, Fastify and Koa are backend frameworks that run on Node.js.
  • Node.js uses a single-threaded event loop with non-blocking input and output, which suits APIs and real-time apps.
  • Node.js is not a programming language either; the language you write is JavaScript or TypeScript.
  • For job interviews, explain the difference between runtime, framework and library with a Node.js and Express example.

Is Node.js a framework? Runtime vs framework vs library

These three words get mixed up a lot, so here is the simple version.

TermWhat it meansExample
Runtime environmentThe software that actually executes your code and gives it access to the systemNode.js, Deno, Bun, the browser
FrameworkA structure that calls your code and decides how the application is organisedExpress, NestJS, Angular
LibraryA collection of functions that your code calls when it needs themLodash, React, Axios

A helpful rule: you call a library, but a framework calls you. A runtime sits below both of them. Node.js is in that bottom layer.

What Node.js actually is

Before Node.js was released in 2009, JavaScript ran almost only inside web browsers. Node.js took the V8 engine from Chrome and wrapped it with extra features that a server needs:

  • Built-in modules such as fs for files, http for web servers, path, os, crypto and events.
  • An event loop powered by the libuv library, which handles many connections without creating a thread for each one.
  • npm, the package manager that ships with Node.js and gives access to a huge registry of packages.

Here is a tiny web server written with only Node.js, no framework:

const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello from Node.js');
});

server.listen(3000, () => console.log('Running on port 3000'));

This works, but as soon as you add routing, request body parsing, validation and error handling, the code becomes messy. That is exactly the gap a framework fills.

Popular frameworks built on Node.js

Express

Express is the most widely used minimal framework for Node.js. It adds routing and middleware with very little setup, and it is the E in the MERN stack.

const express = require('express');
const app = express();

app.use(express.json());

app.get('/api/courses', (req, res) => {
  res.json([{ id: 1, name: 'DevOps' }]);
});

app.listen(3000);

NestJS

NestJS is an opinionated framework written in TypeScript. It uses modules, controllers and dependency injection, so large teams can keep big codebases organised.

Fastify and Koa

Fastify focuses on speed and low overhead with built-in schema validation. Koa was created by the original Express team and uses modern async functions for a lighter core.

Next.js

Next.js is a React framework that runs on Node.js for server-side rendering and API routes. It shows how a runtime can host frameworks for both frontend and backend work.

Why people call Node.js a framework

  • Job posts often list Node.js next to Django or Spring Boot, which are frameworks, so it looks like the same kind of thing.
  • Many tutorials teach Node.js and Express together and blur the line between them.
  • Node.js includes enough built-in modules to build a basic server alone, which feels framework-like.

The fair comparison is Express vs Django or NestJS vs Spring Boot, not Node.js vs Django. Node.js is closer to the Python interpreter or the Java Virtual Machine.

Is Node.js a language?

No. The language is JavaScript, or TypeScript that compiles to JavaScript. Node.js is the place where that code runs. This is similar to how Python is the language and CPython is the program that runs it. We explain the language side in is JavaScript a programming language.

What Node.js is good and not so good at

Good fit

  • REST and GraphQL APIs
  • Real-time apps such as chat and live dashboards using WebSockets
  • Command-line tools and build tools
  • Full stack projects where one team uses JavaScript on both sides

Weaker fit

  • Heavy CPU work such as video encoding or large number crunching on the main thread, because it can block the event loop. Worker threads help, but other languages may suit these jobs better.

How to answer this in an interview

A clean answer sounds like this: Node.js is an open-source, cross-platform JavaScript runtime built on the V8 engine. It is not a framework. It provides an event-driven, non-blocking model and built-in modules, and frameworks such as Express and NestJS are built on top of it. Then give one example of each. You can practise more questions like this in our Node js interview questions, and see a similar debate in is React a framework or library.

Frequently asked questions

Is Node.js frontend or backend?

Node.js is mainly used for the backend, such as APIs and servers. It is also used on developer machines to run frontend build tools, but the code it runs there is not shipped to the browser as Node.js.

Is Express a framework or a library?

Express is usually described as a minimal web framework for Node.js, because it controls the request flow and calls your route handlers and middleware.

Should I learn Node.js or Express first?

Learn core JavaScript and basic Node.js first, including modules, the event loop and async code. Then learn Express, because it will make much more sense once you know what it is simplifying.

Is Node.js single-threaded?

Your JavaScript runs on a single main thread with an event loop, but Node.js uses a background thread pool for some tasks like file access, and you can create worker threads for CPU-heavy work.

Explore more web development guides in our full stack category.

Other articles

Radium4 — IT training blog

Practical, plain-English guides for DevOps, cloud, data, Python, testing and security learners.