Detect current Locale

How to detect the currently selected locale so that you can use it in your React components.

To detect the currently selected locale from the client or the server, you can use the useTranslation hook from next-i18next.

import { useTranslation } from 'next-i18next'; function Component() { const { i18n } = useTranslation(); const { language } = i18n; // use language here }

Subscribe to our Newsletter
Get the latest updates about React, Remix, Next.js, Firebase, Supabase and Tailwind CSS