0.0.7 • Published 11 months ago

next-i18n-middleware v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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 
0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago