@nestjs/config
The official NestJS configuration module for loading, validating, and injecting environment variables.
Repository Health
Technical Analysis
@nestjs/config is the official configuration module for the NestJS framework. It wraps the widely-used dotenv package to load environment variables from .env files and process.env, then exposes them through an injectable ConfigService that integrates with Nest’s dependency injection system.
The module supports namespaced and custom configuration factories, schema validation (via Joi or class-validator), variable expansion through dotenv-expand, and both global and feature-scoped configuration registration, making it the standard way NestJS applications manage environment-driven settings across different deployment environments.
What You Get
- An injectable ConfigService for type-safe access to configuration values throughout the application
- ConfigModule.forRoot()/forFeature() for global and namespaced configuration registration
- Built-in dotenv and dotenv-expand support for loading and interpolating .env files
- Schema validation hooks for Joi or class-validator to fail fast on misconfigured environments
- Conditional module loading via ConditionalModule based on environment variable presence
- Custom configuration factories for grouping related settings into namespaced objects
Common Use Cases
- Loading environment-specific settings (database URLs, API keys, ports) into a NestJS app
- Validating required environment variables at startup so misconfiguration fails immediately
- Sharing typed configuration namespaces across multiple feature modules
- Conditionally registering modules based on which environment variables are present
Under The Hood
Architecture - The module centers on ConfigModule (config.module.ts) which registers a ConfigHostModule providing the underlying key-value store, and ConfigService (config.service.ts) which exposes get()/getOrThrow() methods with type inference; ConditionalModule (conditional.module.ts) allows conditionally importing modules based on env var presence. Tech Stack - Built in TypeScript on top of dotenv and dotenv-expand for environment loading and variable interpolation, with es-toolkit for utility functions; peer dependencies on @nestjs/common and @nestjs/core tie it directly into Nest’s DI container, and optional peers on joi and class-validator support schema validation. Code Quality - The tests/ directory contains 25 TypeScript test files covering module registration, service resolution, and validation paths, run via Vitest; the project uses oxlint for linting and enforces commit conventions via commitlint and husky pre-commit hooks. API Design - The API follows Nest’s conventional forRoot()/forFeature() static module pattern familiar to any Nest developer, minimizing the learning curve; ConfigService.get<T>() provides generic type inference for typed config namespaces, and the official docs site provides a dedicated configuration tutorial.
Used by 17 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
Amplication
Developer Tools · AI Code Assistants · Automation
Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.
Bigcapital
Invoicing Finance
Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.
Cal.diy
Scheduling
The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.
Docmost
Productivity · Note Taking · Collaboration
Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.
Ghostfolio
Invoicing Finance
Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Laudspeaker
Marketing · Automation
Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.
NocoDB
No Code Platforms · Databases · Low Code Platforms
Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.