#1438·nest

Add dynamic routing

Author: BrunnerLivioCreated Jan 12, 2019Updated Sep 7, 2026
Labelstype: question 🙌scope: coreeffort3: weekspriority: low (4)
## I'm submitting a...

[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
## Current behavior At the moment there is no way to register a route dynamically except by using the internal HTTP / Fastify / Express instance (related #124): ```ts const expressInstance = express(); expressInstance.use(morgan('dev')); const app = NestFactory.create(ApplicationModule, expressInstance); expressInstance.get('/foo', function (req, res) { res.send('bar'); }) ``` The problem with this approach is, Nest does internally not recognize this route. Therefore it will not show up in the e.g. swagger integration. ## Expected behavior I wish to have a dynamic router as part of the public Nest API, or at least a way to tell Nest to use an external route inside its router registry. ## What is the motivation / use case for changing the behavior? nestjs/terminus routes do not get registered because it directly modifies the HTTP instance. Therefore there is no Swagger integration or compatibility with middleware. Related: [nest/terminus#32](https://github.com/nestjs/terminus/issues/32) [nest/terminus#33](https://github.com/nestjs/terminus/issues/33) other integrations such as @zMotivat0r for example uses this rather "hacky" workaround (sorry :P): https://github.com/nestjsx/crud/blob/e255120b26dd8ca0eae9c7ec9dac4f893051f447/src/crud.module.ts#L5-L15 or nest-router by @shekohex uses what I would consider the internal API: https://github.com/shekohex/nest-router/blob/3759c688b285792d7889b52f75fffb0e86d4dd54/src/router.module.ts#L53-L56 ## Environment

Nest version: 5.x.x

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others: