Fastify is a Node.js web framework built specifically for speed, maintained by the Fastify team under the OpenJS Foundation. It sits around #25 in web framework usage at roughly 2.9% share. It offers a plugin architecture and schema-based request/response validation, aimed at teams that have outgrown Express's raw performance ceiling for high-throughput APIs and want built-in JSON schema validation instead of bolting on a separate library.
Fastify routes can attach a JSON schema, which the framework uses both to validate incoming requests and to serialize the response fast.
const fastify = require('fastify')({ logger: true })
const schema = {
querystring: {
type: 'object',
properties: { name: { type: 'string' } }
}
}
fastify.get('/greet', { schema }, async (request, reply) => {
const { name } = request.query
return { message: `Hello, ${name || 'World'}!` }
})
fastify.listen({ port: 3000 })
Add Fastify to a Node project with npm, then write a minimal server file and run it directly with Node.
# install Fastify into a new project
npm init -y
npm install fastify
# run the server
node server.js