# General Translation React SDKs (gt-react, gt-next): App Router middleware URL: https://generaltranslation.com/en-US/docs/react/nextjs/app-router-middleware.mdx --- title: App Router middleware description: How to configure General Translation locale routing for the Next.js App Router. related: links: - /docs/react/nextjs-quickstart - /docs/react/nextjs/app-router-static-site-generation - /docs/react/nextjs/reference/functions/create-next-middleware --- Configure middleware, a `[locale]` root segment, and a request locale function so App Router requests resolve to the correct localized route. ## Configure the middleware [#middleware] Create `proxy.ts` in your project root (`middleware.ts` on Next.js 15 and earlier): ```ts title="proxy.ts" import { createNextMiddleware } from 'gt-next/middleware'; export default createNextMiddleware(); export const config = { matcher: ['/((?!api|static|.*\\..*|_next).*)'], }; ``` The middleware detects the locale from the URL, cookie, browser headers, or default locale. It then redirects or rewrites the request to the matching localized route. ## Add the locale route [#locale-route] Move your App Router pages under `app/[locale]`: The route segment receives the locale selected by the middleware. See [`createNextMiddleware`](/docs/react/nextjs/reference/functions/create-next-middleware) for routing options and localized path configuration. ## Read the root locale [#root-locale] Create `getLocale.ts` at your project root. `withGTConfig` detects this file automatically. ```ts title="./getLocale.ts" import { locale } from 'next/root-params'; export default async function getLocale() { return await locale(); } ``` The root parameter supplies the locale without reading request headers or cookies. ## Next steps - /docs/react/nextjs-quickstart - /docs/react/nextjs/app-router-static-site-generation - /docs/react/nextjs/reference/functions/create-next-middleware