Rehooks

useLang

Returns the user’s current browser language based on their settings.

useLang

Installation

npx rehooks-cli@latest add useLang

Usage

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

API

useLang

useLang.ts
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