# Middlewares customization
🤓 Different types of middlewares
In Strapi, 2 middleware concepts coexist:
Strapi middlewares are configured and enabled for the entire Strapi server application. These middlewares can be applied at the application level or at the API level.
The present documentation describes how to implement them.
Plugins can also add Strapi middlewares (see Server API documentation).
Route middlewares have a more limited scope and are configured and used as middlewares at the route level. They are described in the routes documentation.
A new application-level or API-level middleware can be implemented:
- with the interactive CLI command
./src/middlewares/for application-level middlewares
./src/api/[api-name]/middlewares/for API-level middlewares
./src/plugins/[plugin-name]/middlewares/for plugin middlewares
Middlewares working with the REST API are functions like the following:
Once created, custom middlewares should be added to the middlewares configuration file or Strapi won't load them.
Example of a custom timer middleware
The GraphQL plugin also allows implementing custom middlewares, with a different syntax.
Middlewares are called different ways depending on their scope:
global::middleware-namefor application-level middlewares
api::api-name.middleware-namefor API-level middlewares
plugin::plugin-name.middleware-namefor plugin middlewares
To list all the registered middlewares, run
yarn strapi middlewares:list.