Nest
Nest

How can we use the new {*splat} wildcard syntax correctly in NestJS route decorators for v5?

March 18, 2026

Express v5 (NestJS 11+) killed plain * wildcards; you now need named wildcards like {*splat} or /*splat to match any path segments properly without breaking your routes.​

Replace old @Get('users/*') with @Get('users/{*splat}') or @Get('users/*splat')—the braces make it optional (matches root too) while the name satisfies Express v5's stricter rules. NestJS auto-converts some old syntax, but named wildcards are the safe, future-proof way. Use this for catch-all routes, file uploads, or API versioning.​

Code

//OLD (broken/unreliable in Express v5/NestJS 11+)
@Get('users/*')
findAll() {
  return 'Matches users/anything';
}

//NEW (Express v5 correct - recommended)
@Get('users/{*splat}')  // Matches users/, users/123, users/abc/def
findAll(@Param('splat') path: string) {
  return `Caught: ${path}`;
}

// Or path-style
@Get('files/*splat')
download(@Param('splat') filePath: string) {
  return `Serving: ${filePath}`;
}

// Guard usage too
@UseGuards(AuthGuard)
@UseInterceptors(FileInterceptor('file'))
@Put('uploads/{*splat}')
upload(@Param('splat') path: string, @UploadedFile() file: Express.Multer.File) {
  return `Uploaded to: ${path}`;
}
      
Hire Now!

Need Help with Nest Development ?

Ready to leverage the power of conversational AI? Start your project with Zignuts expert AI developers.
bg-image
download-image
Company Deck
PDF, 3MB
© 2026 Zignuts Technolab. All Rights Reserved.
branch imagesbranch imagesbranch imagesbranch imagesbranch imagesbranch images