Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

useLocale

Hooks & Utilities

useLocale React hook in TypeScript

useKeyboardInsetuseLongPress
Live props
Options
locale
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useLocale
Free

useLocale React hook in TypeScript

v1.0.0·Added in 1.0.0

A React hook for the locale numbers, dates and prices are formatted with, the same on the server and in the browser.

The card formats one price, one date and one count with the resolved locale. Leave the locale empty to follow the page and the browser (after hydration), or pick one to see a component's own locale prop win. The provider example pins de-DE for everything inside it, on the server too.

useLocale is a free React hook in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add use-locale.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add use-locale

Usage

Import useLocale from @/hooks/use-locale.

import { LocaleProvider, useLocale } from "@/hooks/use-locale"

export function Price({ value, locale }: { value: number; locale?: string }) {
  const resolved = useLocale(locale)
  return <span>{new Intl.NumberFormat(resolved, { style: "currency", currency: "USD", currencyDisplay: "narrowSymbol" }).format(value)}</span>
}

export function App({ children }: { children: React.ReactNode }) {
  // everything inside formats as en-GB, on the server and in the browser
  return <LocaleProvider locale="en-GB">{children}</LocaleProvider>
}

API

  • localedefault ""
    string

    useLocale(locale?): a component's own locale prop, which wins when set. Empty falls back to the nearest LocaleProvider, then (after hydration) <html lang> and the browser's language.

  • returns
    string

    A canonical BCP 47 tag. On the server and during hydration it is the provider's locale or DEFAULT_LOCALE ("en-US"), so both renders print the same text; the browser's language arrives right after.

Parts

  • LocaleProvider

    component

    Pins the locale for everything inside it, on the server too, so nothing swaps after hydration. Put one in the root layout of a Romanian app. Props: ({ locale: string; children }) => JSX.Element.

  • getBrowserLocale

    function

    The page's lang, then navigator.language, for code outside React (event handlers). DEFAULT_LOCALE is the server fallback. Signature: () => string.

  • DEFAULT_LOCALE

    constant

    The fallback locale, "en-US", used on the server and during hydration when no prop or provider sets one.

Examples

One provider per storefront

The same order card under an en-US and an en-GB LocaleProvider: dates and separators follow, the server render matches.

A component's own locale wins

Inside an en-US provider, the second card passes locale="fr-FR" and useLocale returns it first.

Dependencies

No dependencies beyond React.

Files

  • hooks/use-locale.ts

FAQ

Is the useLocale hook free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install useLocale?

Run npx wingo-ui@latest add use-locale. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/use-locale.json.

See also

Number formatlibDate utilslibuseMediaQueryhook

Used in

Listing cardGaugeAvatar UploadCalendarSliderFavorite buttonKanbanFile managerLocation MapRadial barTrackerHeatmap calendar

and 88 more.

More React hooks and utilities

useLongPresshookuseMediaControlshookuseOverflowItemshookusePersistedStatehookuseScrollEdgeshookuseScrollStatehook
All 36 React hooks and utilities
PrevioususeKeyboardInsetNext useLongPress

useLocale()

en-US
Price
$1,234.50
Published
September 23, 2026
Views
12,480

LocaleProvider de-DE

de-DE
Price
1.234,50 $
Published
23. September 2026
Views
12.480