Skip to main content

usePreferredLanguages

usePreferredLanguages is a hook that returns the user's preferred languages as an array of strings. It uses the navigator.languages.

Usage

Live Editor
function Demo() {
  const preferredLanguages = usePreferredLanguages();
  return <div>PreferredLanguages: {JSON.stringify(preferredLanguages)}</div>;
}
Result
Loading...

API

UsePreferredLanguages

Returns

string[]: preferred languages

Arguments

ArgumentDescriptionTypeDefaultValue
defaultLanguagesdefaule valuestring[] | undefined-