Fastify is what happens when you get tired of Express being slow as hell. Built from scratch in 2016 by Matteo Collina and Tomas Della Vedova, it's a Node.js framework that actually gives a damn about performance.
While Express grew organically from simpler times, Fastify was built from day one to be fast as hell. The difference shows - Fastify handles around 100k+ requests per second while Express tops out around 20k. Your mileage will vary, but it's roughly 5x faster depending on what you're doing.
Why Teams Switch to Fastify
Express Devs Hit Performance Walls: When your Express API starts choking under load, that's when teams look at Fastify. The TechEmpower benchmarks consistently show Fastify in the top tier for JSON APIs. You can throw more servers at the problem, or you can get 5x the performance from the same hardware.
Schema Validation Actually Works: Express middleware is a pain in the ass for API validation. Fastify's JSON Schema approach looks scary at first but saves your ass later. The AJV validator underneath compiles schemas into fast validation functions. No more "works on my machine but crashes in production" surprises from malformed requests. Check out the validation documentation for examples.
TypeScript Support That Doesn't Suck: Unlike Express where you fight with @types/express for 3 hours, Fastify's types just work. The TypeScript support isn't just native - it's actually usable. The type definitions are maintained by the core team, not community volunteers.
The Plugin System (Once You Get Used to It)
Fastify's plugin system is different enough that some Express middleware won't work. Each plugin gets its own context - no shared state unless you explicitly allow it. This prevents the namespace pollution you get with Express, but expect to spend a weekend figuring out why your auth middleware broke.
// Plugin automatically scoped - no conflicts possible
fastify.register(async function (fastify, opts) {
fastify.decorate('utility', () => 'plugin-specific')
// This stays in this plugin's context
})
The schema stuff looks like academic bullshit at first, but it'll save you from debugging mystery API failures at 3am. Schema compilation speeds up responses but eats 30% more memory on startup - your t3.micro instances will OOM on deploy if you're not careful. Pro tip: Set trustProxy: true
or watch your rate limiting explode when you're behind a load balancer. The fluent-json-schema library makes building complex schemas less like pulling teeth.
Migration Reality Check
Migrating from Express isn't just changing imports - it's rewriting everything and questioning your life choices. You'll rewrite route handlers, turn middleware into hooks, and add schemas to routes that never had them. Don't believe anyone who says it's a weekend project. Most teams report about 2-3 weeks to migrate small APIs, assuming nothing breaks. Spoiler: something always breaks.
Express devs need to wrap their heads around:
- Request lifecycle hooks instead of middleware chains
- JSON Schema validation for every route
- Plugin encapsulation that actually prevents conflicts
- Decorators for extending Fastify instances
- Logging with Pino instead of console.log debugging
As of September 2025, Fastify v5.6.0 requires Node.js 20+ since v18 went End-of-Life on April 30, 2025. Current LTS is v22 (Active) and v20 (Maintenance). The upgrade path from v4 is mostly smooth, but earlier v5.x versions had some memory issues, stick with v5.3.0+. Yes, I learned this the hard way during a product launch when our API started eating 2GB of RAM per request.
When NOT to Use Fastify
Don't use Fastify if you have a small CRUD app and don't care about performance. Express has way more Stack Overflow answers and tutorials. Fastify's documentation is good, but Express's ecosystem is massive.
Also skip it if your team isn't ready to learn new concepts. The schema validation and plugin system have a learning curve that might not be worth it for simple applications.