fastify /fastify

Fast and low overhead web framework, for Node.js

★ 37,394⑂ 3,053👁 350⑃ 4,509● 2,213▤ 333◈ 308
JavaScriptMITCreated 2016-09-28www.fastify.dev
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 w

Top issues

Discussions

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

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON