Author:
    Creation:2026-09-19Last update:2026-09-19

    Intlayer Context Documentation

    In remix-intlayer, Intlayer is the RequestContext key used to access internationalization state within Remix 3 request handlers.

    Usage

    When the intlayer() middleware runs, it stores an IntlayerState object in the request context under the Intlayer key. You can retrieve it inside any route handler:

    src/server.ts
    import { createRouter } from "remix/router";
    import { intlayer, Intlayer } from "remix-intlayer";
    
    const router = createRouter({
      middleware: [intlayer()],
    });
    
    router.get("/api/profile", (context) => {
      // Access via context.get(Intlayer)
      const { locale, defaultLocale, availableLocales } = context.get(Intlayer);
    
      return Response.json({
        locale,
        defaultLocale,
        availableLocales,
      });
    });
    

    You can also access it using the direct property shorthand context.intlayer:

    ts
    router.get("/api/status", (context) => {
      const currentLocale = context.intlayer.locale;
      return Response.json({ status: "ok", locale: currentLocale });
    });
    

    IntlayerState Structure

    The IntlayerState object contains:

    PropertyTypeDescription
    localeDeclaredLocalesThe locale resolved for the current request.
    defaultLocaleDeclaredLocalesThe fallback locale defined in intlayer.config.ts.
    availableLocalesDeclaredLocales[]The list of all supported locales configured for the project.