37,394
stars
+16+54+140
3,053
forks
350
watchers
4,509
prs
2,213
issues
333
releases
308
discussions
README
An efficient server implies a lower cost of the infrastructure, better
responsiveness under load, and happy users. How can you efficiently handle the
resources of your server, knowing that you are serving the highest number of
requests possible, without sacrificing security validations and handy
development?
Enter Fastify. Fastify is a web framework highly focused on providing the best
developer experience with the least overhead and a powerful plugin architecture.
It is inspired by Hapi and Express and as far as we know, it is one of the
fastest web frameworks in town.
The main branch refers to the Fastify v6 release.
Check out the 5.x branch for v5.
Table of Contents
- Quick start
- Install
- Example
- Core features
- Benchmarks
- Documentation
- Ecosystem
- Support
- Team
- Hosted by
- License
Quick start
Create a folder and make it your current working directory:
sh
mkdir my-app
cd my-app
Generate a Fastify project with npm init:
sh
npm init fastify
Install dependencies:
sh
npm i
To start the app in dev mode:
sh
npm run dev
For production mode:
sh
npm start
Under the hood npm init downloads and runs Fastify
Create, which in turn uses the
generate functionality of Fastify CLI.
Install
To install Fastify in an existing project as a dependency:
sh
npm i fastify
Example
js
// Require the framework and instantiate it
// ESM
import Fastify from 'fastify'
const fastify = Fastify({
logger: true
})
// CommonJS
const fastify = require('fastify')({
logger: true
})
// Declare a route
fastify.get('/', (request, reply) = {
reply.send({ hello: 'world' })
})
// Run the server!
fastify.listen({ port: 3000 }, (err, address) = {
if (err) throw err
// Server is now listening on ${address}
})
With async-await:
js
// ESM
import Fastify from 'fastify'
const fastify = Fastify({
logger: true
})
// CommonJS
const fastify = require('fastify')({
logger: true
})
fastify.get('/', async (request, reply) = {
reply.type('application/json').code(200)
return { hello: 'world' }
})
fastify.listen({ port: 3000 }, (err, address) = {
if (err) throw err
// Server is now listening on ${address}
})
Do you want to know more? Head to the Getting Started.
If you learn best by reading code, explore the official demo.
Note
.listen binds to the local host, localhost, interface by default
(127.0.0.1 or ::1, depending on the operating system configuration). If
you are running Fastify in a container (Docker,
GCP, etc.), you may need to bind to 0.0.0.0. Be
careful when listening on all interfaces; it comes with inherent
security
risks.
See the documentation for more
information.
Core features
- Highly performant: as far as we know, Fastify is one of the fastest web
frameworks in town, depending on the code complexity we can serve more than 76
thousand requests per second.
- Extensible: Fastify is fully extensible via its hooks, plugins, and
decorators.
- Schema-based: even if it is not mandatory wTop issues
#2748Automate releases47 comments · 2020-12-18#5061Removal of declaration merging43 comments · 2023-09-25#4967ApplicationHooks have inconsistent reference to instance31 comments · 2023-08-12#6834V6 Planning28 comments · 2026-07-07#5215Option to align route params with schema at startup27 comments · 2023-12-15#5984Automate plugins release and rotate keys automatically21 comments · 2025-02-12#3618Categorize Fastify Plugins21 comments · 2022-01-13#4434eslint plugin for fastify?20 comments · 2022-11-21
Discussions
#7178Relia: monitoring for Fastify apps that explains incidents in plain words0 comments · 2026-11-02#7015Bounty scope request: one-time Firebase initialization in Serverless guide (help#1042)0 comments · 2026-09-10#6970Add a dedicated "Dependency Injection" section to the official Guides docs1 comments · 2026-08-20#6931Idempotency plugin for Fastify1 comments · 2026-08-09#6863Bringing Convention over Configuration to Fastify with @syora/fastify0 comments · 2026-07-22#6777[removed]0 comments · 2026-06-10#6703Big memory usage improvement in fast-json-stringify2 comments · 2026-04-30#6626OraClaw -- Decision intelligence API built on Fastify 5 (19 algorithms, sub-25ms)0 comments · 2026-03-30
Latest release
v5.12.8 v5.12.8 2026-11-02⚠️ Security Release Fix for https://github.com/fastify/fastify/security/advisories/GHSA-3qgw-9275-xf8w What's Changed [Backport 5.x] fix(types): restore this context in route shorthand hooks by @github-actions[bot] in https://github.com/fastify/fastify/pull/7055 [Backport 5.x] fix(reply): send stream trailers after the stream actually finishes by @github-actions[bot] in https://github.com/fastify/fastify/pull/7111 [Backport 5.x] test(server): assert the server is listening instead of a literal by @github-actions[bot] in https://github.com/fastify/fastify/pull/7112 [Backport 5.x