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
}