Skip to content

Instantly share code, notes, and snippets.

@nemmtor
nemmtor / nestjs-custom-dynamic-module-mongodb-example.md
Last active September 29, 2025 15:05
NestJS - custom dynamic modules - mongodb example

NestJs has built in ConfigurableModuleBuilder, it is very powerful and satisfies most of cases for dynamic modules:

import { ConfigurableModuleBuilder, Module } from '@nestjs/common';
import { MongoClient } from 'mongodb';

type MongoClientModuleOptions = {
  host: string;
  name: string;
  port: number;
  user: string;