smithery.ai

fastify-best-practices

Guides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript. Use when building, configuring, or debugging a Fastify application — including defining routes, implementing plugins, setting up JSON Schema validation, handling errors, optimising performance, managing authentication, configuring CORS and security headers, integrating databases, working with WebSockets, and deploying to production. Covers the full Fastify request lifecycle (hooks, serialization,…

First seen Mar 6, 2026

Installation

$ npx skills add https://smithery.ai

Summary

  • Guides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript.
  • Use when building, configuring, or debugging a Fastify application — including defining routes, implementing plugins, setting up JSON Schema validation, handling errors, optimising performance, managing authentication, configuring CORS and security headers, integrating databases, working with WebSockets, and deploying to production.
  • Covers the full Fastify request lifecycle (hooks, serialization, logging with Pino) and TypeScript integration via strip types.
  • Trigger terms: Fastify, Node.js server, REST API, API routes, backend framework, fastify.config, server.ts, app.ts.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

More metadata
tags
fastify, nodejs, typescript, backend, api, server, http

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,775 B
  • docs SUMMARY.md 82 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 5 installs

SKILL.md

When to use

Use this skill when you need to:

  • Develop backend applications using Fastify
  • Implement Fastify plugins and route handlers
  • Get guidance on Fastify architecture and patterns
  • Use TypeScript with Fastify (strip types)
  • Implement testing with Fastify's inject method
  • Configure validation, serialization, and error handling

Quick Start

A minimal, runnable Fastify server to get started immediately:

import Fastify from 'fastify'

const app = Fastify({ logger: true })

app.get('/health', async (request, reply) => {
  return { status: 'ok' }
})

const start = async () => {
  await app.listen({ port: 3000, host: '0.0.0.0' })
}
start()

Recommended Reading Order for Common Scenarios

  • New to Fastify? Start with plugins.mdroutes.mdschemas.md
  • Adding authentication: plugins.mdhooks.mdauthentication.md
  • Improving performance: schemas.mdserialization.mdperformance.md
  • Setting up testing: routes.mdtesting.md
  • Going to production: logging.mdconfiguration.mddeployment.md

How to use

Read individual rule files for detailed explanations and code examples:

  • [rules/plugins.md](rules/plugins.md) - Plugin development and encapsulation
  • [rules/routes.md](rules/routes.md) - Route organization and handlers
  • [rules/schemas.md](rules/schemas.md) - JSON Schema validation
  • [rules/error-handling.md](rules/error-handling.md) - Error handling patterns
  • [rules/hooks.md](rules/hooks.md) - Hooks and request lifecycle
  • [rules/authentication.md](rules/authentication.md) - Authentication and authorization
  • [rules/testing.md](rules/testing.md) - Testing with inject()
  • [rules/performance.md](rules/performance.md) - Performance optimization
  • [rules/logging.md](rules/logging.md) - Logging with Pino
  • [rules/typescript.md](rules/typescript.md) - TypeScript integration
  • [rules/decorators.md](rules/decorators.md) - Decorators and extensions
  • [rules/content-type.md](rules/content-type.md) - Content type parsing
  • [rules/serialization.md](rules/serialization.md) - Response serialization
  • [rules/cors-security.md](rules/cors-security.md) - CORS and security headers
  • [rules/websockets.md](rules/websockets.md) - WebSocket support
  • [rules/database.md](rules/database.md) - Database integration patterns
  • [rules/configuration.md](rules/configuration.md) - Application configuration
  • [rules/deployment.md](rules/deployment.md) - Production deployment
  • [rules/http-proxy.md](rules/http-proxy.md) - HTTP proxying and reply.from()

Core Principles

  • Encapsulation: Fastify's plugin system provides automatic encapsulation
  • Schema-first: Define schemas for validation and serialization
  • Performance: Fastify is optimized for speed; use its features correctly
  • Async/await: All handlers and hooks support async functions
  • Minimal dependencies: Prefer Fastify's built-in features and official plugins