Next.js automatically prefixes the locale code as the first path segment for localized routes. So the French homepage is at /fr.
import { useTranslation } from 'next-i18next';
export default function Greeting() {
const { t } = useTranslation('common');
return <h1>{t('welcome_message')}</h1>;
}If the 'common' namespace JSON for English contains {"welcome_message": "Hello!"}, what will render on the page?
import { useTranslation } from 'next-i18next'; export default function Greeting() { const { t } = useTranslation('common'); return <h1>{t('welcome_message')}</h1>; }
The t function looks up the key welcome_message in the 'common' namespace and returns "Hello!" which is rendered inside the <h1> tag.
Option A correctly sets defaultLocale to 'en' and includes both locales. The order of keys in the object is irrelevant in JavaScript.
import { useTranslation } from 'next-i18next'; export default function Welcome() { const { t } = useTranslation('common'); return <p>{t('greeting')}</p>; }
If the app is not wrapped with appWithTranslation or the proper provider, the translation hook won't detect locale changes and won't update the text.
Server Components fetch and render translation data on the server, so the client receives fully translated HTML. This reduces client JavaScript and improves SEO.
