Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Rename intlayerMiddleware to intlayerProxy"v8.1.72/25/2026
- "Init doc"v8.0.01/21/2026
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
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 localized path if necessary.
Usage
Description
The middleware performs the following tasks:
- Locale Detection: It checks the URL path, cookies, and
Accept-Languageheader to determine the user's locale. - 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 localized URL.
- 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.