Registry / web-framework / fastify

fastify

JSON →
library1.5.3jsnpmunverified

Fastify is a high-performance web framework for Node.js, currently stable at version 5.8.5. It is designed for minimal overhead and an optimized developer experience, offering a robust foundation for building efficient web applications and APIs. The project maintains an active release cadence, frequently delivering patch updates and critical security fixes, as evidenced by recent CVE advisories like CVE-2026-33806 and CVE-2026-3635. Key differentiators include its focus on raw speed, a powerful and extensible plugin architecture, and native support for JSON schema validation and OpenAPI specifications. Inspired by frameworks such as Hapi and Express, Fastify distinguishes itself by meticulously optimizing server resource utilization to handle a high number of requests without compromising security validations or developer convenience, aiming to provide one of the fastest web frameworks available for Node.js today.

npm install fastify
INSTALL
IMPORT
SIG · FASTIFY
F
fastify
web-frameworkjavascriptv1.5.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Fastify
import Fastify from 'fastify'
import { Fastify } from 'fastify'
Fastify is primarily consumed as a default export function to create an application instance in ESM.
Fastify (CommonJS)
const fastify = require('fastify')({ logger: true })
const { Fastify } = require('fastify')
The CommonJS `require` pattern directly invokes the exported function to create an instance, optionally passing configuration.
Fastify Types
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { FastifyInstance } from 'fastify'
Use `import type` to explicitly import TypeScript types without adding runtime dependencies or affecting bundler output.

Demonstrates how to create a basic Fastify server, define a GET route, and start the server asynchronously.

import Fastify from 'fastify' const fastify = Fastify({ logger: true }) // Declare a route fastify.get('/', async (request, reply) => { reply.send({ hello: 'world' }) }) // Run the server! const start = async () => { try { const address = await fastify.listen({ port: 3000 }) console.log(`Server listening on ${address}`) } catch (err) { fastify.log.error(err) process.exit(1) } } start()
fastify --version
Debug
Known issues
breakingFastify v5.7.2 introduced a strict parser for `content-type` headers, aligning with RFC 9110. Applications relying on malformed or non-standard `content-type` values may experience parsing errors.
fix
Ensure all `content-type` headers conform strictly to RFC 9110. Review and update any custom content type parsers or client requests that send non-compliant headers.
affects: >=5.7.2
breakingMultiple security vulnerabilities (CVE-2026-33806, CVE-2026-3635, CVE-2026-3419, CVE-2026-25224) have been fixed in recent patch releases. Running older versions exposes applications to these known exploits.
fix
Upgrade Fastify to the latest patch release (v5.8.5 or newer) immediately to incorporate all critical security fixes. Regularly monitor Fastify's GitHub security advisories.
affects: <5.8.5
gotchaThe `reply.send()` method can only be called once per request. Calling it multiple times will result in an error or unexpected behavior, particularly in asynchronous route handlers.
fix
Ensure that `reply.send()` is called exactly once per request lifecycle. For conditional responses, use `if/else` or other control flow mechanisms to prevent multiple calls.
affects: >=1.0.0
Errors
Common errors & fixes
Address already in use :::3000
The server attempted to listen on a port (e.g., 3000) that is already occupied by another process.
fix
Choose an available port for your Fastify application, or terminate the process currently using the desired port. You can use tools like `lsof -i :3000` (macOS/Linux) or `netstat -ano | findstr :3000` (Windows) to identify the conflicting process.
TypeError: fastify is not a function
This error typically occurs when attempting to call `fastify()` without correctly importing the default export (e.g., using a named import `import { fastify } from 'fastify'` or incorrect `require` syntax for the default export).
fix
For ESM, ensure you use `import Fastify from 'fastify'`. For CommonJS, use `const Fastify = require('fastify')`. Remember that `Fastify` is a function that creates an instance, not a class to be `new`-ed.
FST_ERR_BAD_URL: URL must be a string
This error often indicates that a route path or an external request URL provided to Fastify is not a valid string.
fix
Verify that all route definitions (e.g., `fastify.get('/my-route', ...)` or `fastify.register(plugin, { prefix: '/api' })`) and any URLs passed to Fastify's utility functions are correctly formatted string literals.
Upgrade
Version history
1.5.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fastify — npm install fastify · libregistry