> ## Documentation Index
> Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# useLocale

> Get the user's locale.

<Badge color="yellow">sunpeak API</Badge>

## Overview

The `useLocale` hook returns the user's locale string from the host. It is a convenience wrapper around `useHostContext`.

<Card horizontal title="Wraps onhostcontextchanged" icon="cube" href="/mcp-apps/app/event-handlers/onhostcontextchanged">
  MCP Apps SDK reference
</Card>

## Import

```tsx theme={null}
import { useLocale } from 'sunpeak';
```

## Signature

```tsx theme={null}
function useLocale(): string
```

## Returns

<ResponseField name="return" type="string">
  BCP 47 locale string (e.g., `'en-US'`). Defaults to `'en-US'` when unavailable.
</ResponseField>

## Usage

```tsx theme={null}
import { useLocale } from 'sunpeak';

function MyResource() {
  const locale = useLocale();

  const formatted = new Intl.NumberFormat(locale).format(1234.56);
  return <p>{formatted}</p>;
}
```

The locale value comes from [`McpUiHostContext.locale`](/mcp-apps/types/core-types#mcpuihostcontext).
