Skip to content
FrameworkStyle

useLocale

React hook that returns the active BCP 47 locale from the nearest I18nProvider

useLocale returns the resolved BCP 47 tag from the nearest I18nProvider, or 'en' when none is mounted.

Use it when UI copy depends on the active locale outside the translator — for example formatting or caption language hooks.

import { useLocale } from '@videojs/react/i18n';

function LocaleBadge() {
  const locale = useLocale();
  return <span lang={locale}>{locale}</span>;
}

API Reference

Return Value

Type Details
string & object | 'hr' | 'th' | 'tr' ...