KoderSolution Logo
HomeArticlesTutorialsForumAI LabRun Code
KoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Engineering Newsletter

Join 100,000+ engineers receiving curated high-signal content weekly.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
▲

Next.js

Topic Hub & Articles

Next.js Intro

10 min

Recap Quiz

5 Questions

Next.js Installation

10 min

Next.js Routing

10 min

Next.js Pages

10 min

Recap Quiz

5 Questions

Next.js App Router

10 min

Next.js Layouts

10 min

Next.js Linking and Navigating

10 min

Recap Quiz

5 Questions

Next.js Loading UI and Streaming

10 min

Next.js Error Handling

10 min

Next.js Data Fetching

10 min

Recap Quiz

5 Questions

Next.js Server Actions

10 min

Next.js Rendering

10 min

Next.js CSS Modules

10 min

Recap Quiz

5 Questions

Next.js Image Optimization

10 min

Next.js Font Optimization

10 min

Next.js Script Optimization

10 min

Recap Quiz

5 Questions

Next.js Static File Serving

10 min

Next.js Metadata

10 min

Next.js API Routes

10 min

Recap Quiz

5 Questions

Next.js Middleware

10 min

Next.js Authentication

10 min

Next.js Deployment

10 min

Recap Quiz

5 Questions

Next.js Internationalization

10 min

Next.js Security

10 min

Next.js Performance

10 min

Progress
0%

0 / 25 Lessons

Next.jsNext.js Tutorial
Lesson

Next.js Internationalization

10 min reading
Free Course

Next.js Internationalization: Building Multi-Language Web Applications

Next.js Internationalization (i18n) explains how to translate application interfaces, manage dynamic locale routing, and deliver localized metadata.

Internationalized applications use subpath URL segments (like /en/about or /es/about) to target different language preferences.

Dynamic Locale Directory Setup

Organize your App Router using a dynamic [lang] subfolder segment:

app/
└── [lang]/
    ├── layout.tsx
    ├── page.tsx
    └── about/
        └── page.tsx

Creating Dictionary Translation Files

Define key-value translation dictionaries for supported languages:

// dictionaries/en.json
{
  "welcome": "Welcome to our website!",
  "about": "About Us"
}
// dictionaries/es.json
{
  "welcome": "¡Bienvenido a nuestro sitio web!",
  "about": "Sobre Nosotros"
}

Loading Translations in Server Components

Load dictionary files inside async Server Components dynamically:

// app/[lang]/page.tsx
const dictionaries = {
  en: () => import('@/dictionaries/en.json').then((module) => module.default),
  es: () => import('@/dictionaries/es.json').then((module) => module.default),
};

export default async function HomePage({
  params,
}: {
  params: Promise<{ lang: 'en' | 'es' }>;
}) {
  const { lang } = await params;
  const dict = await dictionaries[lang]();

  return (
    <main className="p-8">
      <h1 className="text-3xl font-bold">{dict.welcome}</h1>
    </main>
  );
}

Detecting Browser Locales in Middleware

Redirect users automatically to their preferred browser language in middleware.ts:

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

const locales = ['en', 'es'];
const defaultLocale = 'en';

export function middleware(request: NextRequest) {
  const { pathname } = request.nextUrl;
  const pathnameHasLocale = locales.some(
    (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
  );

  if (pathnameHasLocale) return;

  // Redirect to default locale if missing in URL
  request.nextUrl.pathname = `/${defaultLocale}${pathname}`;
  return NextResponse.redirect(request.nextUrl);
}

export const config = {
  matcher: ['/((?!_next|favicon.ico|api).*)'],
};

Best Practices

  • Set Proper lang Attributes on HTML Tags: Pass locale parameters into the Root Layout <html> tag for accessibility and browser support.
  • Use Subpath Routing for SEO: Prefer /en/about and /es/about subpaths so search engines index localized page variations cleanly.

Summary

i18n routing in Next.js enables multi-language support. Combining dynamic [lang] routes with dictionary files delivers clean localized experiences globally.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Recommended Courses & Books

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum