Most next-intl guides reach for middleware. It reads the Accept-Language
header, guesses a language and redirects. That is convenient, but it costs a
function invocation per request and turns a static site into a dynamic one.
For a personal site that is the wrong trade. The language lives in the path, and everything else is static. The configuration stays small:
export const routing = defineRouting({
locales: ["de", "en"],
defaultLocale: "de",
// Locale detection needs middleware; deliberately off here.
localeDetection: false,
});
What that removes
Without middleware there is no rewrite on the request path. The localized URL is
the real route, and every page calls setRequestLocale(locale) before the first
translation lookup — otherwise it quietly falls back to dynamic rendering:
export default async function Page({ params }: Props) {
const { locale } = await params;
setRequestLocale(locale);
return <Content />;
}
The result is a folder of static files. No function call per request, no vendor lock-in, and moving hosts stays possible at any time.
How this site runs
You are reading this article on a site that is built exactly this way. There is
no middleware file. A request for / is sent to /de with a static redirect
that the configuration sets at build time:
async redirects() {
return [{ source: "/", destination: "/de", permanent: false }];
},
Both languages are prebuilt, and there is no third one. An unknown language in the path therefore lands on the 404 page instead of being rendered on demand:
export function generateStaticParams() {
return routing.locales.map((locale) => ({ locale }));
}
export const dynamicParams = false;
The language switch in the top right does not guess anything either. It
replaces the language in the address and translates the path, so /en/projects
becomes /de/projekte. This article has a German version. The two point at each
other in their frontmatter, which is why the page offers the switch at the top.
You can see how it looks by opening the site's source view.