> ## 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.

# useUserAgent

> Get the host application identifier.

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

## Overview

The `useUserAgent` hook returns the host application identifier string from [`McpUiHostContext.userAgent`](/mcp-apps/types/core-types#mcpuihostcontext). This is an opaque string set by the host — not the browser's `navigator.userAgent`. It is a convenience wrapper around `useHostContext`.

<Note>
  The format and content of this string is host-defined. Not all hosts report a user agent, so the value may be `undefined`.
</Note>

**Known host values:**

| Host    | `userAgent` value                                    |
| ------- | ---------------------------------------------------- |
| ChatGPT | `"chatgpt"`                                          |
| Claude  | Browser user-agent string (e.g. `"Mozilla/5.0 ..."`) |

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

## Import

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

## Signature

```tsx theme={null}
function useUserAgent(): string | undefined
```

## Returns

<ResponseField name="return" type="string | undefined">
  The host application identifier string, or `undefined` if the host does not report one.
</ResponseField>

## Usage

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

function MyResource() {
  const userAgent = useUserAgent();

  return <p>Host: {userAgent ?? 'unknown'}</p>;
}
```
