> For the complete documentation index, see [llms.txt](/llms.txt).
> The full corpus is at [llms-full.txt](/llms-full.txt).

# Editor API overview

> Hooks for accessing the Portable Text Editor instance and deriving state with selectors.

The editor API provides access to the editor instance and selectors for deriving state.

Use the following hooks to access the editor from within your components.

## `useEditor`

Access the editor instance. Commonly used when building toolbars or passing snapshot to selectors.

```tsx
import {useEditor} from '@portabletext/editor'

const editor = useEditor()
```

## `useEditorSelector`

Access selectors in areas where the snapshot is available by combining with `useEditor`.

```tsx
import {useEditor, useEditorSelector} from '@portabletext/editor'
import * as selectors from '@portabletext/editor/selectors'

const editor = useEditor()
const isActive = useEditorSelector(editor, selectors.isActiveDecorator('em'))
```