next-i18n-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

next-i18n-middleware

This is a package created to handle i18n in Next.js projects.

Install

# NPM
npm install --save next-i18n-middleware

Example

// middleware.ts at the root of the project

import { createMiddleware } from "next-i18n-middleware";

export default createMiddleware({
  // A list of all locales that are supported
  locales: ["en", "de"],

  defaultLocale: "en",
});

export const config = {
  // Skip all paths that should not be internationalized
  matcher: ["/((?!api|_next|.*\\..*).*)"],
};
// app/[locale]/layout.tsx

export default function RootLayout({ children, params: { locale } }) {
// pass locale to your i18n lib
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

File Structure

├── middleware.ts 
└── app
    └── [locale]
        ├── layout.tsx 
        └── page.tsx 

Package Sidebar

Install

npm i next-i18n-middleware

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

6.3 kB

Total Files

15

Last publish

Collaborators

  • ppfuenmayor