NestJSInterview preparation
Foundation·Concept·2 min read

Dynamic module vs global module?

Practice this question

Definition:

A dynamic module creates its module definition from supplied configuration, making a feature reusable in different environments. A global module makes its exported providers broadly available after registration. Dynamic describes configuration behavior; global describes visibility, so these are independent properties.

Key points:

  • A dynamic module returns module settings and providers based on configuration.

  • A global module makes exported providers available across the app after registration.

  • Use global modules sparingly so dependencies stay easy to follow.

  • A configured database or integration module can expose a provider without every consumer knowing how it was constructed.

Interview point:

  • Prefer explicit imports for feature dependencies so the app remains understandable and independently testable.
Adapted from 03_NESTJS.md · “Dynamic module vs global module?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.