> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Function: useMainThreadObject()

> **useMainThreadObject**\<`I`, `O` _extends_ `object`>(`objectType`: [`MainThreadObjectType`](/next/api/react/Interfaces/MainThreadObjectType.md)\<`I`, `O`>, `initialValue`: `I`): `O`

Create a stable handle that resolves to an object of the supplied type in
main-thread functions.

This primitive is intended for library hooks. The returned target type is
only callable in a main-thread function; it must not be used from the
background runtime.

## Type Parameters

| Type Parameter         |
| ---------------------- |
| `I`                    |
| `O` _extends_ `object` |

## Parameters

| Parameter      | Type                                                                                    | Description                                   |
| -------------- | --------------------------------------------------------------------------------------- | --------------------------------------------- |
| `objectType`   | [`MainThreadObjectType`](/next/api/react/Interfaces/MainThreadObjectType.md)\<`I`, `O`> | Definition used to realize the target object. |
| `initialValue` | `I`                                                                                     | JSON-serializable initialization payload.     |

## Returns

`O`

The main-thread-only target type.
