Creation:2026-01-21Last update:2026-02-25

    intlayerProxy (intlayerMiddleware) Documentation

    The intlayerProxy (intlayerMiddleware for nextjs < 16) function is a Next.js middleware that handles locale-based routing and redirects. It automatically detects the user's preferred locale and redirects them to the appropriate localised path if necessary.

    Usage

    Description

    The middleware performs the following tasks:

    1. Locale Detection: It checks the URL path, cookies, and Accept-Language header to determine the user's locale.
    2. Redirection: If the URL does not contain a locale prefix and the configuration requires one (or based on the user's preferences), it redirects to the localised URL.
    3. Cookie Management: It can store the detected locale in a cookie for future requests.

    Parameters

    The function takes the standard Next.js NextRequest as a parameter when used directly, or it can be exported as shown above.

    Configuration

    To configure the middleware, you can set up the routing option in the intlayer.config.ts file. See configuration for more details.