Current page: {{ pageId }}
```
## Practical examples
### Read selected nodes
```ts
const editor = useEditor()
const selected = editor.getSelectedNodes()
```
### Trigger commands
```ts
const editor = useEditor()
editor.zoomToFit()
editor.undoAction()
```
## Error behavior
If called outside an editor provider tree, `useEditor()` throws with a helpful message.
That is intentional — this API should fail loudly when the editor context is missing.
## Related APIs
- [provideEditor](./provide-editor)
- [useCanvas](./use-canvas)
- [useSelectionState](./use-selection-state)
- [useEditorCommands](./use-editor-commands)
## Type
```ts
function useEditor(): Editor
```