Previously, it was complex to use next-international's middleware with custom code or external middlewares (e.g. next-auth). The improved createI18nMiddleware function now accepts a full middleware-like signature ((request: NextRequest) => NextResponse) as the first argument, meaning you can very easily add custom logic:
export const middleware = createI18nMiddleware(request => {
// Any custom logic using a raw `NextRequest` and returning a raw `NextResponse`
return NextResponse.next()
}, {
locales: ['en', 'fr'],
defaultLocale: 'en'
});
Improved middleware
Previously, it was complex to use next-international's middleware with custom code or external middlewares (e.g. next-auth). The improved
createI18nMiddleware
function now accepts a full middleware-like signature ((request: NextRequest) => NextResponse
) as the first argument, meaning you can very easily add custom logic:Before
After