In this chapter, we will learn what makes Fastify different from the majority of other web frameworks. In fact, contrary to several other frameworks that have the concept of middleware, Fastify is based on hooks. They all have different use cases, and mastering their usage is key to developing stable and production-ready server applications.
Even if the topic is considered somehow complex, the goal of the subsequent sections is to give a good overview of how the Fastify framework “thinks” and build the right confidence in using these tools.
Before going into their details, though, we need to introduce another concept that makes everything even possible. Namely, we need to learn about the lifecycle of Fastify applications.
In this chapter, we will focus on these concepts:
- What is a lifecycle?
- Declaring hooks
- Understanding the application lifecycle
- Understanding the request and reply lifecycle