Welcome to the Next.js Multilingual Starter, a boilerplate designed to help you quickly set up and build multilingual applications with Next.js and Next-Intl.
- Next.js 15: Leverage the power of the latest Next.js features and the App Router
- Next-Intl: A seamless internationalization (i18n) library for managing multiple languages and locales.
- Simple Setup: Get up and running with multilingual support in just a few steps.
- Scalable Architecture: Easily extend your app with additional languages, components and pages.
- Next.js: A React framework for building fast, dynamic web apps.
- Next-Intl: A powerful library to manage translations and localizations in Next.js.
- Tailwind CSS : This starter comes with Tailwind CSS preconfigured, allowing you to easily build modern, responsive user interfaces. Tailwind's utility-first approach makes it easy to style your components without writing custom CSS, resulting in faster development and a cleaner codebase.
- Clone the repository:
git clone https://github.com/aminagr/nextjs-i18n-starter.git
cd next-i18n-starte
- Install dependencies:
npm install
- Run the app:
npm run dev
To add a new language, follow these steps:
- Update the
locales
array in therouting.js
file. This file is where your application handles the supported locales (languages). Add the language code for your new language (e.g., es for Spanish, de for German) to the array. - Inside the messages/ folder create a new file named after the language code you added. For example, if you added Spanish (es), create a new file called es.json. For example :
{
"hello": "Hola",
"welcome": "Bienvenido"
}
To add a new page, you can follow the structure provided by the Next.js App Router. For example, to add an "About" page:
- Create a new folder called
about
insidesrc/app/[locale]/
. - Inside the
about
folder, create apage.js
file for your new page content.
To add a new component, create it inside the components
folder:
- Create a new file for your component inside the
src/components/
directory (e.g.,MyComponent.js
). - Use the component inside any page or layout by importing it.
Use the useTranslations hook to access the translations dynamically.
import { useTranslations } from 'next-intl';
const AboutPage = () => {
const t = useTranslations();
return <h1>{t('hello')}</h1>;
};
Feel free to fork this repo and open pull requests for any improvements, bug fixes, or new features. Your contributions are always welcome!
This project is licensed under the MIT License - see the LICENSE file for details