Skip to content

Fastify

A fast, low-overhead web framework for building servers and APIs with Node.js.

Stars
37.3k
Forks
3k
Licence
MIT
Language
JavaScript
Last update
4 days ago
Type
Library

What it is

Fastify is a framework for building web servers and APIs in Node.js. You define routes, such as a URL that returns data, and Fastify handles incoming requests with minimal extra work per request. It also offers a plugin system, input and output validation using JSON Schema, and built-in logging through Pino.

  • Build a JSON REST API with routes that validate request bodies
  • Serve an HTTP endpoint that returns a response with logging enabled
  • Structure a backend into plugins using the encapsulation model
  • Write tests for routes using the testing guide in the docs

Great for

  • Node.js developers building JSON APIs or backend services
  • Teams that care about request throughput and want a lightweight framework
  • Projects that want schema-based validation of routes and responses
  • Developers who want to organize code into reusable plugins

Not ideal for

  • Beginners who have not yet learned Node.js basics, since the framework assumes JavaScript familiarity
  • Projects that need a non-Node.js language, because Fastify is for Node.js only
  • Teams expecting a large built-in feature set; much functionality comes from plugins, per the docs
Step-by-step guide: how to use FastifyInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install Fastify in an existing project

    npm i fastify

    Generate a new Fastify project

    npm init fastify
  2. 2

    Run it

    • Create a folder and run npm init fastify inside it
    • Run npm i to install dependencies
    • Start the app in dev mode with npm run dev
    • Open the local address the server reports and check the response
  3. 3

    Get the most out of it

    • Turn on logger: true to get structured logs via Pino
    • Use JSON Schema on routes to validate inputs and serialize outputs
    • Organize features into plugins and use encapsulation to scope them
    • Read the Testing and Benchmarking guides in the docs before relying on performance claims

Downloads

Strengths

  • The README reports high request throughput in a synthetic hello-world benchmark, with the caveat that real results depend on the application
  • Supports JSON Schema validation and serialization for routes
  • Includes a plugin architecture and hooks for extending behavior

Trade-offs

  • Benchmark figures come from the maintainers' own synthetic test and may not match your workload
  • The README's benchmark table lists an older Fastify version (4.0.0), so the numbers are not current
  • Binding to 0.0.0.0 in containers requires care, since the README warns of security risks

How it compares

ProjectStarsTypeLevelUpdatedBest for
fastify (this)37.3kLibrarybeginner4 days agoNode.js developers building JSON APIs or backend services
express69.6kFrameworkintermediate4 days agoDevelopers building JavaScript or Node.js back-end servers
koa35.7kLibraryintermediate4 days agoNode.js developers who want a minimal web framework they can shape themselves
Betterfox11kOtherbeginner2 months agoFirefox users who want privacy-focused defaults without installing extra software
fiber40.2kLibraryintermediate4 days agoGo developers building REST APIs or web backends
gin89.5kLibraryintermediate27 days agoGo developers building REST APIs

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.