@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
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Pezzo
AI Development · Monitoring
Open-source LLMOps platform for prompt management, AI observability, intelligent caching, and real-time cost tracking across LLM providers.
Refly
AI Development · Automation · No Code Platforms
Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.
Swetrix
Analytics
Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.
Teable
Databases · No Code Platforms
A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.
ToolJet
AI Agents · Low Code Platforms · No Code Platforms
Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.
Trench
Analytics · Data Engineering · Monitoring
Open-source event tracking infrastructure built on Kafka and ClickHouse that handles thousands of events per second on a single node, with full Segment API compatibility and no cookies.
twenty
CRM
The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.