@Global()

Marks a module as global so its exported providers are available everywhere without importing it.

Since NestJS 10/11 Spec ↗

Syntax

@Global()

Returns

ClassDecorator — A decorator applied to a module class.

Examples

import { Module, Global } from '@nestjs/common';
import { ConfigService } from './config.service';

@Global()
@Module({
  providers: [ConfigService],
  exports: [ConfigService],
})
export class ConfigModule {}

Notes

Register the global module once (typically in the root module). Its exported providers can then be injected anywhere without re-importing. Use sparingly; explicit imports keep dependencies clear.