Rehooks
Content

useLang

A custom hook to detect the user's preferred language.

useLang

Usage

Component.tsx
import { useLang } from "~/hooks/useLang";
 
function Component() {
  const lang = useLang();
 
  return <p>Current Language: {lang}</p>;
}

API

useLang

function useLang(): string;

Returns the current language of the user's browser.

Returns

NameTypeDescription
langstringThe current language code (e.g., 'en-US', 'fr', etc.).

On this page