Configure multi-language localization in Next.js 15 App Router. Implement subpath routing, language middleware, translated metadata, and hreflang tags. This practical guide covers step-by-step setup, real-world code snippets, security hardening, and common production edge cases.
Executive Summary & Key Takeaway (AEO)
Next.js 15 App Router replaces the legacy Pages Routeri18nconfiguration innext.config.jswith declarative subpath routing folders (app/[locale]/...) and Edge Middleware. This architecture enables complete localization of static routes, dynamic dictionary imports, and correct Googlehreflangalternates—ensuring global search engines index localized regional variants without canonical cannibalization.
App Router Folder Hierarchy for Multi-Language Routing
In the App Router, every localized page lives under a dynamic [locale] segment:
app/
├── [locale]/
│ ├── layout.tsx # Root layout reading locale param
│ ├── page.tsx # Localized home page
│ ├── about/
│ │ └── page.tsx
│ └── blog/
│ └── [slug]/
│ └── page.tsx
├── dictionaries/
│ ├── en.json
│ ├── de.json
│ └── fr.json
└── middleware.ts # Detects browser Accept-Language and rewrites URL
Step 1: Locale Detection Middleware (middleware.ts)
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
const locales = ['en', 'de', 'fr'];
const defaultLocale = 'en';
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
// Ignore static assets, api routes, and public files
if (
pathname.startsWith('/_next') ||
pathname.startsWith('/api') ||
pathname.startsWith('/images') ||
pathname.includes('.')
) {
return;
}
// Check if pathname already contains a supported locale prefix
const pathnameHasLocale = locales.some(
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
);
if (pathnameHasLocale) return;
// Extract preferred language from browser Accept-Language header
const acceptLanguage = request.headers.get('accept-language') || '';
const preferred = locales.find((locale) => acceptLanguage.includes(locale)) || defaultLocale;
request.nextUrl.pathname = `/${preferred}${pathname}`;
return NextResponse.redirect(request.nextUrl);
}
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};
Step 2: Dictionary Loader & Typesafe Server Component
// lib/dictionary.ts
import 'server-only';
const dictionaries = {
en: () => import('@/dictionaries/en.json').then((module) => module.default),
de: () => import('@/dictionaries/de.json').then((module) => module.default),
fr: () => import('@/dictionaries/fr.json').then((module) => module.default),
};
export const getDictionary = async (locale: string) => {
const load = dictionaries[locale as keyof typeof dictionaries] || dictionaries.en;
return load();
};
Rendering translated strings inside a server component:
// app/[locale]/page.tsx
import { getDictionary } from '@/lib/dictionary';
import type { Metadata } from 'next';
interface Props {
params: Promise<{ locale: string }>;
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { locale } = await params;
const dict = await getDictionary(locale);
return {
title: dict.meta.title,
description: dict.meta.description,
alternates: {
canonical: `https://devpatternlabs.com/${locale}`,
languages: {
'en-US': 'https://devpatternlabs.com/en',
'de-DE': 'https://devpatternlabs.com/de',
'fr-FR': 'https://devpatternlabs.com/fr',
'x-default': 'https://devpatternlabs.com/en',
},
},
};
}
export default async function LocalizedHomePage({ params }: Props) {
const { locale } = await params;
const dict = await getDictionary(locale);
return (
<main className="max-w-4xl mx-auto py-12 px-4">
<h1 className="text-3xl font-bold text-white">{dict.home.headline}</h1>
<p className="text-slate-300 mt-4 leading-relaxed">{dict.home.subtext}</p>
</main>
);
}
Technical SEO: Google Hreflang Validation
Ensure each regional alternate links to all other language variants plus an x-default fallback. Failing to declare symmetric links causes Google Search Console to emit the "No return tags" error.
Global Application Engineering by Dev Pattern Labs
Building a multilingual platform for global enterprise markets? Dev Pattern Labs architects multi-tenant, localized Next.js web apps. Explore our 14-Day Delivery Sprint or schedule an engineering consultation at Dev Pattern Labs.
Companion SEO & Architecture Tutorials
Written by Dev Pattern LabsCore Engineering
Dev Pattern Labs is an engineering lab and digital consultancy specializing in custom Next.js web applications, WooCommerce REST API integrations, and workflow automation for growing businesses.
Recommended Companion Articles

Dynamic Open Graph Image Generation with Next.js 15 and @vercel/og
Generate dynamic, high-converting Open Graph social preview cards in Next.js 15 using Satori and Edge Runtime. Boost social CTR and SEO indexation.

Next.js 15 and Supabase RLS: Complete Multi-Tenant Security Guide
Implement Postgres Row Level Security (RLS) in Next.js 15 and Supabase. Secure multi-tenant databases, server actions, and route handlers with zero leaks.

Next.js 15 Partial Prerendering: Complete Architecture Guide
Master Next.js 15 Partial Prerendering (PPR). Combine instant static shells with dynamic streaming Suspense holes for lightning-fast Core Web Vitals.
