Dev Pattern Labs logo
Dev Pattern Labs Blog
Next.js 3 min readNov 13, 2026

Next.js 15 Internationalization: App Router Multi-Language Guide

Configure multi-language localization in Next.js 15 App Router. Implement subpath routing, language middleware, translated metadata, and hreflang tags.

Dev Pattern Labs Author

Dev Pattern Labs

Peer-reviewed technical tutorial · Production tested

Global communication network map representing multilingual web internationalization
Executive Summary & Key Insight

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 Router i18n configuration in next.config.js with declarative subpath routing folders (app/[locale]/...) and Edge Middleware. This architecture enables complete localization of static routes, dynamic dictionary imports, and correct Google hreflang alternates—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

Tags:#Next.js#i18n#Localization#App Router#Technical SEO
Dev Pattern Labs Engineering Team

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