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…











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 v5 release.
Check out the 4.x branch for v4.
Table of Contents
- [Quick start](#quick-start)
- [Install](#install)
- [Example](#example)
- [Core features](#core-features)
- [Benchmarks](#benchmarks)
- [Documentation](#documentation)
- [Ecosystem](#ecosystem)
- [Support](#support)
- [Team](#team)
- [Hosted by](#hosted-by)
- [License](#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
> https://snyk.io/blog/mongodb-hack-and-secure-defaults/" rel="noopener nofollow" target="_blank">security
> risks.
> See [the documentation](./docs/Reference/Server.md#listen) for more
> information.
Core features
- Highly performant: as far as we know, Fastify is one of the fastest web
- Extensible: Fastify is fully extensible via its hooks, plugins, and
- Schema-based: even if it is not mandatory we recommend using JSON
- Logging: logs are extremely important but are costly; we chose the best
- Developer friendly: the framework is built to be very expressive and help
Benchmarks
__Machine:__ EX41S-SSD, Intel Core i7, 4Ghz, 64GB RAM, 4C/8T, SSD.
__Method__: autocannon -c 100 -d 40 -p 10 localhost:3000 * 2, taking the
second average
| Framework | Version | Router? | Requests/sec |
| :----------------- | :------------------------- | :----------: | ------------: |
| Express | 4.17.3 | ✓ | 14,200 |
| hapi | 20.2.1 | ✓ | 42,284 |
| Restify | 8.6.1 | ✓ | 50,363 |
| Koa | 2.13.0 | ✗ | 54,272 |
| Fastify | 4.0.0 | ✓ | 77,193 |
| - | | | |
| http.Server | 16.14.2 | ✗ | 74,513 |
These benchmarks taken using https://github.com/fastify/benchmarks. This is a
synthetic "hello world" benchmark that aims to evaluate the framework overhead.
The overhead that each framework has on your application depends on your
application. You should __always__ benchmark if performance matters to you.
Documentation
- [__
Getting Started__](./docs/Guides/Getting-Started.md) - [__
Guides__](./docs/Guides/Index.md) - [__
Server__](./docs/Reference/Server.md) - [__
Routes__](./docs/Reference/Routes.md) - [__
Encapsulation__](./docs/Reference/Encapsulation.md) - [__
Logging__](./docs/Reference/Logging.md) - [__
Middleware__](./docs/Reference/Middleware.md) - [__
Hooks__](./docs/Reference/Hooks.md) - [__
Decorators__](./docs/Reference/Decorators.md) - [__
Validation and Serialization__](./docs/Reference/Validation-and-Serialization.md) - [__
Fluent Schema__](./docs/Guides/Fluent-Schema.md) - [__
Lifecycle__](./docs/Reference/Lifecycle.md) - [__
Reply__](./docs/Reference/Reply.md) - [__
Request__](./docs/Reference/Request.md) - [__
Errors__](./docs/Reference/Errors.md) - [__
Content Type Parser__](./docs/Reference/ContentTypeParser.md) - [__
Plugins__](./docs/Reference/Plugins.md) - [__
Testing__](./docs/Guides/Testing.md) - [__
Benchmarking__](./docs/Guides/Benchmarking.md) - [__
How to write a good plugin__](./docs/Guides/Write-Plugin.md) - [__
Plugins Guide__](./docs/Guides/Plugins-Guide.md) - [__
HTTP2__](./docs/Reference/HTTP2.md) - [__
Long Term Support__](./docs/Reference/LTS.md) - [__
TypeScript and types support__](./docs/Reference/TypeScript.md) - [__
Serverless__](./docs/Guides/Serverless.md) - [__
Recommendations__](./docs/Guides/Recommendations.md)
Ecosystem
- [Core](./docs/Guides/Ecosystem.md#core) - Core plugins maintained by the
- [Community](./docs/Guides/Ecosystem.md#community) - Community-supported
- Live Examples - Multirepo with a broad
- Discord - Join our discord server and
Support
Please visit Fastify help to view prior support issues and to ask new support questions.Version 3 of Fastify and lower are EOL and will not receive any security or bug
fixes.
Fastify's partner, HeroDevs, provides commercial security fixes for all
unsupported versions at [https://herodevs.com/support/fastify-nes][hd-link].
Fastify's supported version matrix is available in the
[Long Term Support][lts-link] documentation.
Contributing
Whether reporting bugs, discussing improvements and new ideas, or writing code,
we welcome contributions from anyone and everyone. Please read the [CONTRIBUTING](./CONTRIBUTING.md)
guidelines before submitting pull requests.
Team
_Fastify_ is the result of the work of a great community. Team members are
listed in alphabetical order.
Lead Maintainers:
,
,
,
Fastify Core team
, , , , , , , ,Fastify Plugins team
, , , , , , ,Emeritus Contributors
Great contributors to a specific area of the Fastify ecosystem will be invited to join this group by Lead Maintainers when they decide to step down from the active contributor's group. , , , ,- __dalisoft__, ,
Hosted by
[](https://openjsf.org/projects)
We are an At-Large
Project
in the OpenJS Foundation.
Sponsors
Support this project by becoming a [SPONSOR](./SPONSORS.md)!
Fastify has an Open Collective
page where we accept and manage financial contributions.
Acknowledgments
This project is kindly sponsored by:
This list includes all companies that support one or more team members
in maintaining thi
…
Members
-
fastify ★ PINNED
Fast and low overhead web framework, for Node.js
JavaScript ★ 37k 14h agoExplain → -
fast-json-stringify ★ PINNED
2x faster than JSON.stringify()
JavaScript ★ 3.7k 5d agoExplain → -
help ★ PINNED
Need help with Fastify? File an Issue here
★ 68 3d agoExplain → -
demo ★ PINNED
A concrete example of a Fastify application using what are considered best practices by the Fastify community
TypeScript ★ 226 5d agoExplain → -
fastify-cli ★ PINNED
Run a Fastify application with one command!
JavaScript ★ 730 1d agoExplain → -
point-of-view ★ PINNED
Template rendering plugin for Fastify
JavaScript ★ 378 1d agoExplain → -
fastify-vite
Fastify plugin for Vite integration
JavaScript ★ 1.1k 3d agoExplain → -
fastify-swagger
Swagger documentation generator for Fastify
JavaScript ★ 1.1k 2d agoExplain → -
fastify-dx ▣
Archived
JavaScript ★ 882 7mo agoExplain → -
benchmarks
Fast and low overhead web framework fastify benchmarks
JavaScript ★ 628 4d agoExplain → -
fastify-rate-limit
A low overhead rate limiter for your routes
JavaScript ★ 597 4d agoExplain → -
fastify-jwt
JWT utils for Fastify
JavaScript ★ 583 3d agoExplain → -
aws-lambda-fastify
Insipired by aws-serverless-express to work with Fastify with inject functionality
JavaScript ★ 559 5d agoExplain → -
fastify-nextjs
React server side rendering support for Fastify with Next
JavaScript ★ 557 3d agoExplain → -
fastify-multipart
Multipart support for Fastify
JavaScript ★ 543 3d agoExplain → -
fastify-sensible
Defaults for Fastify that everyone can agree on
JavaScript ★ 539 3d agoExplain → -
fluent-json-schema
A fluent API to generate JSON schemas
JavaScript ★ 524 4d agoExplain → -
fastify-static
Plugin for serving static files as fast as possible
JavaScript ★ 496 4d agoExplain → -
fastify-cors
Fastify CORS
JavaScript ★ 492 4d agoExplain → -
avvio
Asynchronous bootstrapping of Node applications
JavaScript ★ 467 4d agoExplain → -
fastify-websocket
basic websocket support for fastify
JavaScript ★ 466 3d agoExplain → -
fastify-helmet
Important security headers for Fastify
JavaScript ★ 462 4d agoExplain → -
light-my-request
Fake HTTP injection library
JavaScript ★ 419 4d agoExplain → -
under-pressure
Process load measuring plugin for Fastify, with automatic handling of "Service Unavailable"
JavaScript ★ 413 5d agoExplain → -
fastify-http-proxy
Proxy your http requests to another server, with hooks
JavaScript ★ 391 4d agoExplain → -
fastify-auth
Run multiple auth functions in Fastify
JavaScript ★ 378 3d agoExplain → -
fastify-autoload
Require all plugins in a directory
JavaScript ★ 371 5d agoExplain → -
fastify-oauth2
Enable to perform login using oauth2 protocol
JavaScript ★ 314 3d agoExplain → -
fastify-passport
Use passport strategies for authentication within a fastify application
TypeScript ★ 302 3h agoExplain → -
fastify-cookie
A Fastify plugin to add cookies support
JavaScript ★ 296 3d agoExplain → -
fastify-example-twitter ▣
Fastify example - clone twitter
JavaScript ★ 278 1y agoExplain → -
middie
Middleware engine for Fastify
JavaScript ★ 275 2d agoExplain → -
fastify-express
Express compatibility layer for Fastify
JavaScript ★ 273 4d agoExplain → -
fastify-mongodb
Fastify MongoDB connection plugin
JavaScript ★ 269 3d agoExplain → -
docs-chinese ▣
Fastify 中文文档
★ 268 1y agoExplain → -
env-schema
Validate your env variables using Ajv and dotenv
JavaScript ★ 258 6d agoExplain → -
secure-json-parse
JSON.parse() drop-in replacement with prototype poisoning protection
JavaScript ★ 243 11d agoExplain → -
fastify-env
Fastify plugin to check environment variables
JavaScript ★ 241 4d agoExplain → -
fastify-plugin
Plugin helper for Fastify
JavaScript ★ 239 3d agoExplain → -
fastify-redis
Plugin to share a common Redis connection across Fastify
JavaScript ★ 229 3d agoExplain → -
fastify-secure-session
Create a secure stateless cookie session for Fastify
JavaScript ★ 228 3d agoExplain → -
fastify-caching
A Fastify plugin to facilitate working with cache headers
JavaScript ★ 228 3d agoExplain → -
fastify-compress
Fastify compression utils
JavaScript ★ 226 3d agoExplain → -
fastify-postgres
Fastify PostgreSQL connection plugin
JavaScript ★ 215 4d agoExplain → -
fastify-request-context
Request-scoped storage support, based on Asynchronous Local Storage (with fallback to cls-hooked)
JavaScript ★ 205 3d agoExplain → -
fastify-type-provider-typebox
A Type Provider for Typebox
JavaScript ★ 203 15h agoExplain → -
fastify-swagger-ui
Serve Swagger-UI for Fastify
JavaScript ★ 193 6d agoExplain → -
fastify-bearer-auth
A Fastify plugin to require bearer Authorization headers
JavaScript ★ 188 2d agoExplain → -
github-action-merge-dependabot
This action automatically approves and merges dependabot PRs
JavaScript ★ 181 2d agoExplain → -
fastify-circuit-breaker
A low overhead circuit breaker for your routes
JavaScript ★ 169 3d agoExplain → -
csrf-protection
A fastify csrf plugin
JavaScript ★ 167 3d agoExplain → -
fastify-reply-from
fastify plugin to forward the current http request to another server
JavaScript ★ 167 4d agoExplain → -
fast-proxy ▣
Node.js framework agnostic library that enables you to forward an http request to another HTTP server. Supported protocols: HTTP, HTTPS, HTTP2
JavaScript ★ 162 2y agoExplain → -
example
Runnable examples of Fastify
JavaScript ★ 152 4d agoExplain → -
create-fastify
Rapidly generate a Fastify project
JavaScript ★ 145 16d agoExplain → -
busboy
A streaming parser for HTML form data for node.js
JavaScript ★ 137 1d agoExplain → -
fastify-formbody
A Fastify plugin to parse x-www-form-urlencoded bodies
JavaScript ★ 136 3d agoExplain → -
fastify-error
A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins
JavaScript ★ 135 18d agoExplain → -
fastify-awilix
Dependency injection support for fastify
JavaScript ★ 132 6d agoExplain → -
session
Session plugin for fastify
JavaScript ★ 127 3d agoExplain → -
deepmerge
Merges the enumerable properties of two or more objects deeply. Fastest implementation of deepmerge
JavaScript ★ 126 17d agoExplain → -
fastify-routes
Decorates fastify instance with a map of routes
JavaScript ★ 125 3d agoExplain → -
fastify-schedule
Fastify plugin for scheduling periodic jobs
JavaScript ★ 119 5d agoExplain → -
fast-uri
Dependency-free RFC 3986 URI toolbox
JavaScript ★ 109 6d agoExplain → -
restartable
Restart Fastify without losing a request
JavaScript ★ 109 7d agoExplain → -
fastify-basic-auth
Fastify Basic auth plugin
JavaScript ★ 93 3d agoExplain → -
fastify-example-todo ▣
A Simple Fastify REST API Example
JavaScript ★ 93 1y agoExplain → -
website
No description.
JavaScript ★ 89 2d agoExplain → -
fastify-funky
Make fastify functional! Plugin, adding support for fastify routes returning functional structures, such as Either, Task or plain parameterless function
JavaScript ★ 87 22h agoExplain → -
fastify-etag
Automatically generate etags for HTTP responses, for Fastify
JavaScript ★ 85 3d agoExplain → -
fastify-hotwire
Use the Hotwire pattern with Fastify
JavaScript ★ 82 4d agoExplain → -
fastify-mysql
Fastify Mysql connection plugin
JavaScript ★ 80 3d agoExplain → -
fastify-accepts
Add an accepts parser to Fastify
JavaScript ★ 79 3d agoExplain → -
website-metalsmith ▣
This project is used to build the website for fastify web framework and publish it online.
HTML ★ 77 3y agoExplain → -
fastify-kafka
Fastify plugin to interact with Apache Kafka
JavaScript ★ 70 4d agoExplain → -
releasify
A tool to release in a simpler way your module
JavaScript ★ 64 14h agoExplain → -
fastify-url-data
A plugin to provide access to the raw URL components
JavaScript ★ 61 3d agoExplain → -
otel
OpenTelemetry instrumentation library
JavaScript ★ 59 6d agoExplain → -
fastify-routes-stats
provide stats for routes using perf_hooks, for fastify
JavaScript ★ 58 3d agoExplain → -
safe-regex2
Detect possibly catastrophic, exponential-time regular expressions
JavaScript ★ 56 2d agoExplain → -
fastify-response-validation
A simple plugin that enables response validation for Fastify
JavaScript ★ 56 4d agoExplain → -
fastify-type-provider-json-schema-to-ts
A Type Provider for json-schema-to-ts
TypeScript ★ 54 4d agoExplain → -
one-line-logger
Helps you format fastify's log into a nice one line message
JavaScript ★ 47 4d agoExplain → -
fastify-elasticsearch
Fastify plugin for Elasticsearch
JavaScript ★ 45 3d agoExplain → -
skeleton
Template repository to create standardized Fastify plugins
JavaScript ★ 38 7d agoExplain → -
process-warning
A small utility for creating warnings and emitting them
JavaScript ★ 38 18d agoExplain → -
fastify-flash
Flash message plugin for Fastify
TypeScript ★ 36 3d agoExplain → -
fastify-accepts-serializer
Serializer according to the accept header
JavaScript ★ 29 18d agoExplain → -
tsconfig
Shared TypeScript configuration for fastify projects
★ 29 2mo agoExplain → -
sse
Server-Sent Events for Fastify
JavaScript ★ 27 2d agoExplain → -
fastify-leveldb ▣
Plugin to share a common LevelDB connection across Fastify
JavaScript ★ 27 3mo agoExplain → -
json-schema-ref-resolver
JSON schema reference resolver
JavaScript ★ 25 18d agoExplain → -
ajv-compiler
Build and manage the AJV instances for the fastify framework
JavaScript ★ 24 6d agoExplain → -
fastify-throttle
Throttle the download speed of a request
JavaScript ★ 23 7d agoExplain → -
any-schema-you-like ▣
Save multiple schemas and decide which one to use to serialize the payload
JavaScript ★ 22 2y agoExplain → -
fastify-early-hints ▣
Draft plugin of the HTTP 103 implementation
JavaScript ★ 22 2y agoExplain → -
fastify-diagnostics-channel ▣
Plugin to deal with diagnostics_channel on Fastify
JavaScript ★ 20 1y agoExplain → -
csrf
CSRF utilities for fastify
JavaScript ★ 18 7d agoExplain → -
docs-korean ▣
No description.
★ 18 1y agoExplain → -
vite-plugin-blueprint ▣
Vite plugin for shadowing files from a blueprint folder.
JavaScript ★ 18 2y agoExplain → -
.github
Default community health files
★ 17 2mo agoExplain → -
docs-portuguese ▣
Portuguese docs for Fastify
★ 17 1y agoExplain → -
fast-json-stringify-compiler
Build and manage the fast-json-stringify instances for the fastify framework
JavaScript ★ 15 13h agoExplain → -
workflows
Reusable workflows for use in the Fastify organization
★ 15 2d agoExplain → -
send
Fork of the send module to deal with CVE-2017-20165
JavaScript ★ 15 4d agoExplain → -
fastify-bankai ▣
Bankai assets compiler for Fastify
JavaScript ★ 15 1y agoExplain → -
pre-commit
Fork of https://github.com/observing/pre-commit
JavaScript ★ 14 4d agoExplain → -
merge-json-schemas
Builds a logical conjunction (AND) of multiple JSON schemas
JavaScript ★ 12 17d agoExplain → -
fastify-typescript-extended-sample ▣
This project is supposed to be a large, fake Fastify & TypeScript app. It is meant to be a reference as well as a pseudo-sandbox for Fastify TypeScript changes
TypeScript ★ 11 5y agoExplain → -
fastify-type-provider-zod ⑂
A Type Provider for Zod
TypeScript ★ 10 2d agoExplain → -
forwarded
Parse HTTP X-Forwarded-For header (fork)
JavaScript ★ 10 2d agoExplain → -
fastify-zipkin
Fastify plugin for Zipkin distributed tracing system.
JavaScript ★ 10 3d agoExplain → -
openapi-schema-diff
A javascript library that compares two OpenAPI schemas and finds breaking changes.
JavaScript ★ 10 7d agoExplain → -
fastify-snippet
Some VSCode snippet about Fastify
JavaScript ★ 10 2mo agoExplain → -
gh-issues-finder
Fetches issues tagged with "good first issue" in a github org
JavaScript ★ 9 2d agoExplain → -
pacchetto
Fastify Package Generator
JavaScript ★ 9 1mo agoExplain → -
fastify-soap-client ▣
Fastify plugin for a SOAP client
JavaScript ★ 9 2y agoExplain → -
fastify-valkey-glide
Plugin to share a common valkey connection across Fastify
JavaScript ★ 8 6d agoExplain → -
fast-content-type-parse
Parse HTTP Content-Type header according to RFC 7231
JavaScript ★ 8 17d agoExplain → -
compile-schemas-to-typescript ▣
Compile JSON Schemas to TypeScript interfaces
JavaScript ★ 8 1y agoExplain → -
proxy-addr
Determine the address of a proxied request
JavaScript ★ 7 2d agoExplain → -
fastify-fetch
Handle requests using the fetch standard
JavaScript ★ 5 3d agoExplain → -
dependabot-merge-action-app ▣
Fastify application to automatically approve and merge Dependabot pull requests.
JavaScript ★ 5 4y agoExplain → -
fastify-type-provider-fluent-json-schema ▣
No description.
★ 5 2y agoExplain → -
deprecate-modules ▣
No description.
JavaScript ★ 5 4y agoExplain → -
fastify-opensearch
Fastify plugin for OpenSearch
JavaScript ★ 4 4d agoExplain → -
accept-negotiator
Negotiate accept headers, fast
JavaScript ★ 4 6d agoExplain → -
graphics
Graphics and logo
★ 4 2mo agoExplain → -
fastify-citgm
CITGM for Fastify
JavaScript ★ 3 5d agoExplain → -
fastify-register-timeout ▣
Register fastify plugin with a timeout
JavaScript ★ 3 4y agoExplain → -
action-pr-title ⑂
Github action to enforce Pull Request title conventions
TypeScript ★ 2 4d agoExplain → -
org-admin
Utilities to handle the organization's permissions
JavaScript ★ 2 6d agoExplain → -
social-posts
Drafts, reviews, and publication pipeline for Fastify community content (social posts & blog articles).
★ 2 2mo agoExplain → -
fastify-jitson ▣
A default jitson parser for Fastify
★ 2 4y agoExplain → -
fastify-template-gitpod
No description.
JavaScript ★ 1 2mo agoExplain → -
fastify-starter-codesandbox ▣
Created with CodeSandbox
JavaScript ★ 0 1y agoExplain → -
fast-formdata-stringify ▣
application/x-www-form-urlencoded stringify according to jsonschema
★ 0 1y agoExplain → -
semver-major-release-script ▣
No description.
★ 0 4y agoExplain → -
fastify-server-timeout ▣
Set timeout for incoming messages
JavaScript ★ 0 5y agoExplain →
No repos match these filters.