JavaScript on the Server with Node.js
Learn Node.js, its event loop, npm and a web framework like Express or Fastify to build HTTP APIs.
Beginner · about 40 hours · difficulty 3/5
Learn first: HTTP in Depth
Node.js runs JavaScript outside the browser on the V8 engine. It is our recommended first backend language because you can use one language across frontend and backend, the package ecosystem (npm) is huge and the job market is large. Pair it with TypeScript as soon as you are comfortable, since types catch many bugs before runtime.
How Node works
Node runs your JavaScript on a single thread with an event loop. I/O (network, disk, database) is non-blocking: you start an operation and continue, and a callback or await resumes when it finishes. This makes Node excellent for I/O-heavy APIs, but a CPU-heavy loop (image processing, big JSON parsing) blocks every other request. Offload such work to worker threads or a separate service.
What to learn
- Modern JavaScript:
async/await, Promises, modules (ESM), destructuring, error handling. - npm or pnpm,
package.json, semantic versioning and lockfiles. - A framework: Express (minimal, ubiquitous), Fastify (fast, schema-first) or NestJS (opinionated, structured).
- Validating input (Zod or similar), middleware, routing, and centralized error handling.
Pitfalls
- Unhandled promise rejections crashing the process. Always
awaitorcatch. - Mixing CommonJS and ESM without understanding the difference.
You are ready to move on when you can build a small CRUD API with routing, validation, error handling and environment-based config, and explain why a synchronous loop hurts every user.
Key concepts
- Event loop and async I/O
- async/await and Promises
- npm, package.json and lockfiles
- TypeScript
- Express
- Fastify
- NestJS
- Input validation with Zod
- Worker threads
Other options for this step
- Python for Backend Development: Use Python with Django, Flask or FastAPI to build readable, productive web services.
- Go for Backend Services: Learn Go's simple syntax, goroutines and standard library to build fast, easily deployed services.
- Java and the Spring Ecosystem: Build enterprise-grade services with Java, Maven or Gradle and Spring Boot.
- C# and ASP.NET Core: Build cross-platform web APIs with C#, .NET and ASP.NET Core.
- PHP and Laravel: Use modern PHP with Laravel or Symfony, the stack behind a large share of the web.
- Ruby on Rails: Build products quickly with Ruby and Rails' convention-over-configuration approach.
- Rust for High-Performance Backends: Use Rust with Axum or Actix for memory-safe, very fast services, accepting a steeper learning curve.
Mini project
Build a TypeScript Express or Fastify API for a bookmarks app with CRUD endpoints, Zod validation, a global error handler and config loaded from environment variables.
Check yourself
What happens to other in-flight requests when one request handler runs a 3-second synchronous loop in Node.js?
Free resources
- Node.js Learn (Node.js)
- Express documentation (Express)
- TypeScript Handbook (TypeScript)