Fumadocs
Internationalization

Middleware

Next.js proxy for implementing i18n routing

Setup

Redirects users to appropriate locale, it can be customised from i18n.ts config file.

proxy.ts
import { createI18nMiddleware } from 'fumadocs-core/i18n/middleware';
import { i18n } from '@/lib/i18n';

export default createI18nMiddleware(i18n);

export const config = {
  // Matcher ignoring `/_next/` and `/api/`
  // You may need to adjust it to ignore static assets in `/public` folder
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};

When hideLocale is enabled, it uses NextResponse.rewrite to hide locale prefixes.

How is this guide?

Last updated on

On this page