Fumadocs rebuilt on Hamur, the original is fumadocs.dev
Skip to Content
Fumadocs

Middleware

Next.js proxy for implementing i18n routing

Setup

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

It's a Next.js proxy. See Internationalization for the setup on React Router, TanStack Start, Waku and Astro.

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