Overview
Fastify is a Node.js web framework inspired by Hapi and Express, built for low overhead. Its website reports around 98,000 requests per second for a simple route and about 1.6 times the throughput of Express in its own illustrative comparison.
Speed comes partly from schemas: routes can declare JSON Schemas for query strings, bodies and responses, which Fastify compiles into validation and serialization functions. With a type provider such as TypeBox, the same schema also gives the handler its TypeScript types. Logging uses Pino, chosen for its low cost.
Everything beyond the core is a plugin. Plugins are encapsulated, so decorators and hooks registered in one context do not leak into others, which keeps large apps modular. The ecosystem lists about 297 plugins, including official ones for CORS, cookies, static files, Swagger/OpenAPI and OpenTelemetry.
The project started in 2016, is part of the OpenJS Foundation, and is maintained by a team of lead maintainers including Matteo Collina. NestJS can use Fastify as its HTTP layer instead of Express.
Pricing and plans
What it does
- Schema validation and serialization
- JSON Schema per route compiled into fast validators and serializers.
- Type providers
- TypeBox and other providers infer request and reply types from route schemas.
- Encapsulated plugins
- Hooks, decorators and plugins scoped to contexts so parts of an app stay isolated.
- Pino logging
- Structured, low-overhead logging built in.
- Official plugins
- CORS, cookies, static files, Swagger/OpenAPI docs and OpenTelemetry among about 297 ecosystem plugins.
Strengths and limitations
Strengths
- High throughput for a Node framework
- Validation, serialization and types from one schema
- Governed under the OpenJS Foundation with several lead maintainers
- Mature plugin ecosystem with official packages
Limitations
- Node.js only; not designed for edge runtimes such as Workers
- Middleware is not supported out of the box since v3; Express middleware needs @fastify/express or @fastify/middie
- Encapsulation rules for plugins and decorators take time to learn
- Major versions have breaking changes (v4 is kept on a separate branch)
Who it suits
Good for
- High-traffic JSON APIs on Node
- Teams wanting schema-first validation and OpenAPI
- NestJS apps that want a faster HTTP layer
Look elsewhere if
- Edge or Bun-first projects (see Hono or Elysia)
- Teams wanting a full MVC stack with ORM and auth
Alternatives to Fastify
| Tool | From | Free option | Stages |
|---|---|---|---|
| Encore Backend framework with infrastructure from code | $49/mo | Free tier | |
| Gin Go HTTP web framework | — | ||
| Ruby on Rails Full-stack Ruby web framework | — | ||
| Laravel Batteries-included PHP framework | $5/mo | ||
| ASP.NET Core .NET web framework | — | ||
| Django Batteries-included Python web framework | — |
Questions
Is Fastify faster than Express?
In Fastify's own comparison it serves about 1.6 times as many requests per second as Express.
Can I use Express middleware with Fastify?
Yes, through the @fastify/express or @fastify/middie plugins.
Does Fastify support TypeScript?
Yes. Types ship with the package and type providers infer types from route schemas.
Who maintains Fastify?
A team of lead maintainers and collaborators; it is an OpenJS Foundation project.
Sources read for this page