{"schemaVersion":"1.0","record":{"label":"Fastify","description":"MIT-licensed Node.js HTTP framework with encapsulated plugins, schema validation, response serialization and request-injection testing.","aliases":[],"kind":"software","website":"https://fastify.dev","overview":"Fastify is an open-source web framework for Node.js. It combines HTTP routes with a plugin system, lifecycle hooks, request validation and response serialization. Its encapsulation model allows different parts of an application to receive different hooks and utilities. This makes it a building block for a custom backend rather than a complete hosted backend product.","license":"MIT","lifecycle":"active","example":false,"features":[{"name":"Scoped plugins and hooks","status":"supported","detail":"Encapsulation determines which decorations, hooks and plugins are visible to routes; child changes do not automatically propagate to parents.","useCase":"Building and testing Node.js HTTP APIs","platforms":["Supported Node.js release lines"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://fastify.dev/docs/latest/Reference/Encapsulation/","locator":"Context inheritance and plugin completion","retrievedAt":"2026-10-07T23:00:41Z","kind":"vendor"}]},{"name":"Schema validation and serialization","status":"supported","detail":"JSON Schema feeds request validation and output serialization; schemas must be trusted application code.","useCase":"Building and testing Node.js HTTP APIs","platforms":["Supported Node.js release lines"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/","locator":"Schema compilation, trusted-schema warning and async validation caution","retrievedAt":"2026-10-07T23:00:26Z","kind":"vendor"}]},{"name":"Arbitrary untrusted schema compilation","status":"unsupported","detail":"Documentation warns that new Function-based compilation is unsafe for user-provided schemas.","useCase":"Building and testing Node.js HTTP APIs","platforms":["Supported Node.js release lines"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/","locator":"Schema compilation, trusted-schema warning and async validation caution","retrievedAt":"2026-10-07T23:00:26Z","kind":"vendor"}]},{"name":"Request-injection tests","status":"supported","detail":"inject simulates HTTP requests after registered plugins have booted; tests can inspect responses without starting a listening server.","useCase":"Building and testing Node.js HTTP APIs","platforms":["Supported Node.js release lines"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://fastify.dev/docs/latest/Guides/Testing/","locator":"Separating application/server and inject plugin readiness","retrievedAt":"2026-10-07T23:00:51Z","kind":"vendor"}]},{"name":"Existing middleware compatibility","status":"limited","detail":"Express-style middleware requires an external plugin and operates on raw Node objects before Fastify Request/Reply wrapping.","useCase":"Building and testing Node.js HTTP APIs","platforms":["Supported Node.js release lines"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://fastify.dev/docs/latest/Reference/Middleware/","locator":"External middleware plugins, raw Node objects and hook alternative","retrievedAt":"2026-10-07T23:01:01Z","kind":"vendor"}]}],"alternatives":[],"slug":"fastify","draftAlternatives":[{"targetSlug":"hono","status":"limited","detail":"Can replace Hono for a Node.js API after rewriting handlers and middleware around Fastify's lifecycle. It does not establish Hono-style Web Standards portability or compatibility with Hono's typed client.","useCase":"Building and testing Node.js HTTP APIs","platforms":["Supported Node.js release lines"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://fastify.dev/docs/latest/","locator":"Framework identity and documentation structure","retrievedAt":"2026-10-07T23:01:01Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Middleware/","locator":"External middleware plugins, raw Node objects and hook alternative","retrievedAt":"2026-10-07T23:01:01Z","kind":"vendor"},{"url":"https://hono.dev/docs","locator":"Web Standards and multi-runtime model","retrievedAt":"2026-10-07T23:00:05Z","kind":"vendor"}]}],"evidence":[{"url":"https://github.com/fastify/fastify/blob/main/LICENSE","locator":"MIT conditions","retrievedAt":"2026-10-07T23:00:26Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/","locator":"Framework identity and documentation structure","retrievedAt":"2026-10-07T23:01:01Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Encapsulation/","locator":"Context inheritance and plugin completion","retrievedAt":"2026-10-07T23:00:41Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/","locator":"Schema compilation, trusted-schema warning and async validation caution","retrievedAt":"2026-10-07T23:00:26Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Guides/Migration-Guide-V5/","locator":"Node baseline, full JSON Schema and changed APIs","retrievedAt":"2026-10-07T23:00:26Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Middleware/","locator":"External middleware plugins, raw Node objects and hook alternative","retrievedAt":"2026-10-07T23:01:01Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Guides/Testing/","locator":"Separating application/server and inject plugin readiness","retrievedAt":"2026-10-07T23:00:51Z","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/LTS/","locator":"Supported runtime lines and security-release compatibility caveat","retrievedAt":"2026-10-07T23:01:01Z","kind":"vendor"},{"url":"https://hono.dev/docs","locator":"Web Standards and multi-runtime model","retrievedAt":"2026-10-07T23:00:05Z","kind":"vendor"}],"document":{"version":1,"references":[{"url":"https://github.com/fastify/fastify/blob/main/LICENSE","locator":"MIT conditions","retrievedAt":"2026-10-07T23:00:26Z","id":"license","title":"Fastify license","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/","locator":"Framework identity and documentation structure","retrievedAt":"2026-10-07T23:01:01Z","id":"intro","title":"Fastify documentation","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Encapsulation/","locator":"Context inheritance and plugin completion","retrievedAt":"2026-10-07T23:00:41Z","id":"encapsulation","title":"Fastify encapsulation","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/","locator":"Schema compilation, trusted-schema warning and async validation caution","retrievedAt":"2026-10-07T23:00:26Z","id":"validation","title":"Fastify validation and serialization","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Guides/Migration-Guide-V5/","locator":"Node baseline, full JSON Schema and changed APIs","retrievedAt":"2026-10-07T23:00:26Z","id":"migration","title":"Fastify v5 migration guide","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/Middleware/","locator":"External middleware plugins, raw Node objects and hook alternative","retrievedAt":"2026-10-07T23:01:01Z","id":"middleware","title":"Fastify middleware","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Guides/Testing/","locator":"Separating application/server and inject plugin readiness","retrievedAt":"2026-10-07T23:00:51Z","id":"testing","title":"Fastify testing guide","kind":"vendor"},{"url":"https://fastify.dev/docs/latest/Reference/LTS/","locator":"Supported runtime lines and security-release compatibility caveat","retrievedAt":"2026-10-07T23:01:01Z","id":"support","title":"Fastify LTS policy","kind":"vendor"},{"url":"https://hono.dev/docs","locator":"Web Standards and multi-runtime model","retrievedAt":"2026-10-07T23:00:05Z","id":"hono","title":"Hono framework overview","kind":"vendor"}],"overviewCitations":["intro","encapsulation","validation"],"licenseCitations":["license"],"sections":[{"id":"plugins","heading":"Structuring an application","paragraphs":[{"id":"plugins-detail","content":[{"text":"Fastify organizes routes and shared behavior through plugins. Encapsulation determines access to decorators, hooks and other plugins: child contexts inherit relevant parent behavior, but parent contexts do not automatically gain their children's additions. This is useful for separating public and restricted API groups, but it also means registration scope matters. In an AI-generated backend, a hook existing somewhere in the project is not evidence that it runs for every intended route."}],"citations":["encapsulation"]}]},{"id":"schemas","heading":"Validation and output boundaries","paragraphs":[{"id":"schemas-detail","content":[{"text":"Fastify recommends JSON Schema for route validation and serialization, using Ajv and fast-json-stringify by default. The schemas are compiled, and the documentation explicitly treats them as application code because compilation uses new Function. They are not safe arbitrary user-submitted configuration. It also advises against database work during initial asynchronous validation, placing such tasks in later hooks. Validation and authorization are therefore separate design steps, even when both concern the same request."}],"citations":["validation"]}]},{"id":"versions","heading":"Version-sensitive generated code","paragraphs":[{"id":"versions-detail","content":[{"text":"The v5 migration guide requires full schemas including their type rather than the older shorthand form. It also changes several interfaces, including custom logger configuration and plugin completion rules. A starter copied from an older example needs more than a package-number update. Although the v5 guide states a Node.js 20-or-newer baseline, the LTS policy ties support to supported Node release lines and their latest releases; the historical minimum should not be treated as a current security-support recommendation."}],"citations":["migration","support"]}]},{"id":"middleware","heading":"Adapting an existing middleware stack","paragraphs":[{"id":"middleware-detail","content":[{"text":"Express-style middleware requires an integration such as @fastify/express or @fastify/middie. That middleware receives underlying Node request and response objects before Fastify wraps them, so Fastify Reply methods are not available there. Native hooks such as preHandler operate at a different stage and have access to Fastify's objects. A migration should choose the appropriate stage for each behavior instead of mechanically moving middleware calls."}],"citations":["middleware"]}]},{"id":"testing","heading":"Testing routes before deployment","paragraphs":[{"id":"testing-detail","content":[{"text":"The testing guide separates the application builder from the listening server and demonstrates fastify.inject. Injection waits for registered plugins to boot and returns a response suitable for assertions. That supports focused tests of generated handlers, validation and errors without opening a listening port. As an assessment, this does not replace checks of a production reverse proxy, external service or actual network deployment; those sit outside the simulated request boundary."}],"citations":["testing"]}]},{"id":"licensing","heading":"License and maintenance","paragraphs":[{"id":"licensing-detail","content":[{"text":"The covered Fastify source is MIT-licensed. Its LTS policy describes maintenance by major version and notes that necessary security fixes can occasionally include breaking changes in a minor release. Teams should read those release notes and test updates rather than equate permissive licensing with maintenance-free operation. Paid end-of-life support described by the project is a separate service, not a condition of the source license."}],"citations":["license","support"]}]},{"id":"replacement","heading":"Substitution considerations","paragraphs":[{"id":"replacement-detail","content":[{"text":"Fastify is a candidate replacement for "},{"text":"Hono","targetSlug":"hono"},{"text":" when the requirement is a custom Node.js HTTP API with scoped plugins and schema-driven request handling. The server programming model and middleware contracts differ, so the comparison does not establish drop-in compatibility or equal runtime reach. Existing clients and response contracts need validation after a rewrite. No hands-on migration, benchmark or security audit was performed."}],"citations":["intro","middleware","hono"]}]}]},"id":"Q1170","revision":1218,"updatedAt":"2026-10-13T23:28:14Z","sourceUrl":"https://substitutefor.net/entities/Q1170?revision=1218"}}