The Fast, Schema-First Node Web Framework
What Fastify Is
Fastify is a Node web framework focused on speed, JSON Schema-based validation, and an encapsulated plugin system.
What you'll learn
- Understand what Fastify is and the performance angle
- See where Fastify fits among Express/Koa/Hapi/NestJS
- Recognize the schema-first design
Fastify is a Node.js web framework created by Matteo Collina that benchmarks roughly twice as fast as Express while shipping a richer feature set — JSON Schema validation, plugin encapsulation, and a fast Pino logger out of the box.
Why Fastify
Where Express stays minimal and unopinionated, Fastify makes a few pointed bets: JSON Schema for request validation and response serialization, async hooks for the request lifecycle, and a plugin system with proper encapsulation. The result is a framework that scales from a single file to a large modular service without changing the mental model.
It is used in production at Microsoft, Heroku, Adidas, and many other shops that need both throughput and predictable structure.
The Schema-First Idea
Most frameworks treat validation as middleware you bolt on. Fastify treats it as a route-level declaration:
app.post('/users', {
schema: {
body: {
type: 'object',
required: ['email'],
properties: { email: { type: 'string', format: 'email' } },
},
response: {
201: { type: 'object', properties: { id: { type: 'integer' } } },
},
},
handler: async (req, reply) => {
const user = await createUser(req.body);
reply.code(201);
return user;
},
}); That single schema validates the request body, serializes the response (via
fast-json-stringify), and — with @fastify/swagger — generates OpenAPI docs.
The Ecosystem in One Sentence
Encapsulated plugins, request/lifecycle hooks, decorators for shared state, Pino-based structured logging, Ajv 8 validation, and a TypeScript-first developer experience.
Installing & First Server →