--- createdAt: 2026-01-21 updatedAt: 2026-09-29 priority: 5 title: intlayer Fastify Plugin Documentation | fastify-intlayer description: "The intlayer plugin for Fastify detects the user's locale and decorates each request with Intlayer translation functions." keywords: - intlayer - fastify - plugin - Intlayer - intlayer - Internationalization - Documentation slugs: - doc - packages - fastify-intlayer - intlayer history: - version: 8.0.0 date: 2026-01-21 changes: "Init doc" author: aymericzip --- # intlayer Fastify Plugin Documentation The `intlayer` plugin for Fastify detects the user's locale and decorates the request object with Intlayer functions. It also enables the use of global translation functions within the request context. ## Usage ```ts import Fastify from "fastify"; import { intlayer } from "fastify-intlayer"; const fastify = Fastify(); fastify.register(intlayer); fastify.get("/", async (req, reply) => { const content = req.intlayer.t({ en: "Hello", fr: "Bonjour", }); return content; }); ``` ## Description The plugin performs the following tasks: 1. **Locale Detection**: It analyzes the request (headers, cookies, etc.) to determine the user's preferred locale. 2. **Request Decoration**: It adds an `intlayer` property to the `FastifyRequest` object, containing: - `locale`: The detected locale. - `t`: A translation function. - `getIntlayer`: A function to retrieve dictionaries.