# usePageMove

Source: https://sdk.pdf.net/docs/v1/reference/usePageMove



Returns functions that move pages to a new position, such as for a drag-to-reorder sidebar.

```ts
const { moveAfter, moveBefore } = usePageMove()

moveAfter(pageIdOrPageIds, afterPageId?)
moveBefore(pageIdOrPageIds, beforePageId?)
```

* `moveAfter` inserts the pages after `afterPageId`; without it, at the end of the document.
* `moveBefore` inserts the pages before `beforePageId`; without it, at the start of the document.
* Several pages move together in the given order, as a single undo step.
* Every id must identify an existing page, or the call throws `InvalidInputError`; with no document loaded, it throws `DocumentNotLoadedError`.

## Example [#example]

```tsx
import { usePageMove } from '@sdk-pdf/react'

function useMovePageToStart() {
  const { moveBefore } = usePageMove()

  return (pageId: string) => moveBefore(pageId)
}
```

