An example of registering the plugin to use Express middleware:

    Remember that middleware can be encapsulated; this means that you can decide where your middleware should run by using register as explained in the plugins guide.

    Restrict middleware execution to a certain path(s)

    If you need to run a middleware only under certain path(s), just pass the path as first parameter to and you are done!

    Fastify offers some alternatives to the most commonly used middleware, such as fastify-helmet in case of , fastify-cors for and for .