# EntityPageState

**Category:** Base Components/Pages/Entity Page/State

## API

### Overview

`EntityPageState` is the state object that drives an [`EntityPage`](./?path=/story/base-components-pages-entity-page--entitypage). It is created by the [`useEntityPage`](./?path=/story/base-components-pages-entity-page-hooks-useentitypage--useentitypage) hook and manages:

- **Entity fetching** — loads the entity from the server via `fetch`
- **Form state** — integrates with `react-hook-form` for editing
- **Save / cancel flow** — calls `onSave` with form values and handles success/error toasts
- **Dirty-form protection** — warns on `beforeunload` when the form has unsaved changes
- **Navigation** — supports both Patterns Router (`parentPath`) and legacy BM navigation (`parentPageId`)

Pass the returned state to `` and use [`useEntity`](./?path=/story/base-components-pages-entity-page-hooks-useentity--useentity) to read the entity reactively.

```tsx
import { useEntityPage } from '@wix/patterns';
// Returns EntityPageState
```

