07 / 07

How do you compose multiple decorators into a single reusable decorator in NestJS?

Use applyDecorators() to bundle multiple decorators — including guards, metadata decorators, and Swagger decorators — into one named decorator. This reduces boilerplate on routes and co-locates all related concerns under a single, intention-revealing name like @Auth() or @ApiPaginatedResponse().

@Auth() composite decorator using applyDecorators
applyDecorators() design guidance:
  1. 1

    Accepts any combination of method and class decorators.

  2. 2

    Decorators are applied in the order listed — first in the array runs first.

  3. 3

    Works for both method-level and class-level composition.

  4. 4

    Ideal for bundling auth + Swagger + metadata decorators that always go together.

  5. 5

    The composed decorator has a meaningful name — @Auth('admin') communicates intent better than 4 separate decorators.