This document describes the core package ecosystem of the NestJS framework, including the foundational packages (@nestjs/core and @nestjs/common), platform adapters for HTTP servers and WebSocket protocols, microservices transport layer, and testing utilities. All packages are versioned together at 11.1.13 and managed through the Lerna monorepo system (see Monorepo Management with Lerna for versioning details). This page focuses on package structure, dependencies, and how packages relate to each other. For information about sample applications that demonstrate these packages, see Sample Applications Guide.
Sources: lerna.json1-5 packages/core/package.json1-64 packages/common/package.json1-42
The NestJS core ecosystem consists of ten primary packages organized into four functional categories: foundational packages, platform adapters, communication protocols, and development tools.
Sources: packages/core/package.json1-64 packages/common/package.json1-42 packages/platform-express/package.json1-36 packages/platform-fastify/package.json1-47 packages/platform-ws/package.json1-30 packages/platform-socket.io/package.json1-30 packages/websockets/package.json1-37 packages/microservices/package.json1-73 packages/testing/package.json1-38
The @nestjs/core package provides the dependency injection container, application lifecycle management, module scanning, and routing infrastructure. It requires Node.js >= 20 and serves as the runtime foundation for all NestJS applications.
Key Dependencies:
@nuxt/opencollective: 0.4.1 - Funding banner displayfast-safe-stringify: 2.1.1 - Safe JSON serializationiterare: 1.2.1 - Iterator utilitiespath-to-regexp: 8.3.0 - Route path parsingtslib: 2.8.1 - TypeScript runtime helpersuid: 2.0.2 - Unique identifier generationPeer Dependencies:
@nestjs/common: ^11.0.0 (required)reflect-metadata: ^0.1.12 || ^0.2.0 (required)rxjs: ^7.1.0 (required)@nestjs/microservices: ^11.0.0 (optional)@nestjs/platform-express: ^11.0.0 (optional)@nestjs/websockets: ^11.0.0 (optional)Sources: packages/core/package.json1-64
The @nestjs/common package contains decorators, pipes, guards, interceptors, exception types, and utility functions used across all NestJS applications.
Key Dependencies:
file-type: 21.3.0 - File MIME type detectioniterare: 1.2.1 - Iterator utilities (shared with core)load-esm: 1.0.3 - ESM module loadingtslib: 2.8.1 - TypeScript runtime helpersuid: 2.0.2 - Unique identifier generation (shared with core)Peer Dependencies:
reflect-metadata: ^0.1.12 || ^0.2.0 (required)rxjs: ^7.1.0 (required)class-transformer: >=0.4.1 (optional, for serialization)class-validator: >=0.13.2 (optional, for validation)Sources: packages/common/package.json1-42
NestJS abstracts HTTP server implementations through platform adapters, allowing applications to switch between Express and Fastify without code changes.
| Package | HTTP Framework | Version | Primary Dependencies | Use Case |
|---|---|---|---|---|
@nestjs/platform-express | Express | 5.2.1 | cors, express, multer, path-to-regexp | Default, broad ecosystem compatibility |
@nestjs/platform-fastify | Fastify | 5.7.4 | @fastify/cors, @fastify/formbody, fastify, find-my-way | High performance, lower overhead |
Sources: packages/platform-express/package.json1-36 packages/platform-fastify/package.json1-47
The default HTTP platform adapter built on Express 5.2.1. Includes integrated file upload support via multer 2.0.2 and CORS handling.
Direct Dependencies:
cors: 2.8.6 - CORS middlewareexpress: 5.2.1 - HTTP server frameworkmulter: 2.0.2 - Multipart form data handlingpath-to-regexp: 8.3.0 - Path matching (shared with core)tslib: 2.8.1 - TypeScript helpersPeer Dependencies:
@nestjs/common: ^11.0.0@nestjs/core: ^11.0.0Sources: packages/platform-express/package.json1-36
High-performance HTTP platform adapter built on Fastify 5.7.4. Uses find-my-way 9.4.0 for optimized routing and light-my-request 6.6.0 for request injection.
Direct Dependencies:
@fastify/cors: 11.2.0 - CORS plugin@fastify/formbody: 8.0.2 - Form body parsingfast-querystring: 1.1.2 - Query string parsingfastify: 5.7.4 - HTTP server frameworkfastify-plugin: 5.1.0 - Plugin registrationfind-my-way: 9.4.0 - Routerlight-my-request: 6.6.0 - Request injectionpath-to-regexp: 8.3.0 - Path matchingreusify: 1.1.0 - Object poolingtslib: 2.8.1 - TypeScript helpersOptional Peer Dependencies:
@fastify/static: ^8.0.0 || ^9.0.0 - Static file serving (see Static File Serving)@fastify/view: ^10.0.0 || ^11.0.0 - Template rendering (see MVC Applications)Sources: packages/platform-fastify/package.json1-47
WebSocket support in NestJS follows a two-layer architecture: the @nestjs/websockets package provides framework abstractions, while platform-specific adapters implement the transport layer.
Sources: packages/websockets/package.json1-37 packages/platform-socket.io/package.json1-30 packages/platform-ws/package.json1-30
Provides the abstract gateway system for WebSocket communication, including decorators like @WebSocketGateway(), @SubscribeMessage(), and @MessageBody(). This package depends on:
iterare: 1.2.1 - Iterator utilitiesobject-hash: 3.0.0 - Object hashing for message patternstslib: 2.8.1 - TypeScript helpersThe package requires @nestjs/platform-socket.io as an optional peer dependency, allowing developers to choose their WebSocket implementation.
Sources: packages/websockets/package.json1-37
Implements WebSocket gateways using Socket.IO 4.8.3, which provides rooms, namespaces, and automatic reconnection. Peer depends on @nestjs/websockets for gateway abstractions.
Sources: packages/platform-socket.io/package.json1-30
Lightweight WebSocket adapter using the native ws 8.19.0 library for standards-compliant WebSocket support without additional features like rooms or namespaces.
Sources: packages/platform-ws/package.json1-30
The @nestjs/microservices package provides a unified abstraction over multiple message broker and RPC protocols. All transport-specific dependencies are marked as optional peer dependencies.
Sources: packages/microservices/package.json1-73
Direct Dependencies:
iterare: 1.2.1 - Iterator utilities (shared with core/common)tslib: 2.8.1 - TypeScript helpersRequired Peer Dependencies:
@nestjs/common: ^11.0.0@nestjs/core: ^11.0.0reflect-metadata: ^0.1.12 || ^0.2.0rxjs: ^7.1.0Optional Peer Dependencies (Transport-Specific):
@grpc/grpc-js: * - gRPC protocol implementationamqplib: * - RabbitMQ AMQP clientamqp-connection-manager: * - RabbitMQ connection poolingkafkajs: * - Apache Kafka clientioredis: * - Redis clientnats: * - NATS messaging system clientmqtt: * - MQTT protocol clientcache-manager: * - Optional caching integration@nestjs/websockets: ^11.0.0 - WebSocket hybrid appsApplications only need to install the transport libraries they actually use. For example, an application using only RabbitMQ would install amqplib and amqp-connection-manager but not the other transport clients.
Sources: packages/microservices/package.json1-73
The @nestjs/testing package provides test utilities for creating isolated testing modules with dependency injection support. It has minimal direct dependencies:
tslib: 2.8.1 - TypeScript helpersPeer Dependencies:
@nestjs/common: ^11.0.0 (required)@nestjs/core: ^11.0.0 (required)@nestjs/microservices: ^11.0.0 (optional)@nestjs/platform-express: ^11.0.0 (optional)The optional peer dependencies allow testing of microservices and HTTP applications without requiring all packages to be installed.
Sources: packages/testing/package.json1-38
Several dependencies are shared across multiple packages, ensuring consistency and reducing bundle size:
| Dependency | Version | Used By | Purpose |
|---|---|---|---|
tslib | 2.8.1 | All packages | TypeScript runtime helpers |
iterare | 1.2.1 | core, common, websockets, microservices | Iterator manipulation utilities |
path-to-regexp | 8.3.0 | core, platform-express, platform-fastify | Route path matching |
uid | 2.0.2 | core, common | Unique identifier generation |
Sources: packages/core/package.json33-39 packages/common/package.json20-25 packages/platform-express/package.json20-25 packages/platform-fastify/package.json20-30
All core packages require these peer dependencies, which must be installed by the consuming application:
reflect-metadata: ^0.1.12 || ^0.2.0 - Decorator metadata reflectionrxjs: ^7.1.0 - Reactive programming primitivesThese are fundamental to NestJS's decorator-based programming model and reactive patterns.
Sources: packages/core/package.json44-51 packages/common/package.json27-32
All packages share the same version number (11.1.13) as specified in lerna.json3 This coordinated versioning strategy ensures compatibility across the ecosystem. When one package is updated, all packages are released together with the same version increment.
The @nestjs/core package specifies "node": ">= 20" in packages/core/package.json12-14 establishing the minimum Node.js version requirement for the entire framework.
Sources: lerna.json1-5 packages/core/package.json1-64
The following diagram shows the complete dependency relationships between core packages, with peer dependencies indicated by dashed lines:
Sources: packages/core/package.json44-62 packages/common/package.json27-40 packages/platform-express/package.json31-34 packages/platform-fastify/package.json32-45 packages/platform-ws/package.json24-28 packages/platform-socket.io/package.json24-28 packages/websockets/package.json24-35 packages/microservices/package.json28-71 packages/testing/package.json23-36
Refresh this wiki