# usePageDelete

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



Returns a function that deletes pages by id, one or several at once as a single undo step.

```ts
const deletePages = usePageDelete()

deletePages(pageId)
deletePages([pageId1, pageId2])
```

* Every id must identify an existing page, or the call throws `InvalidInputError` and deletes nothing; with no document loaded, it throws `DocumentNotLoadedError`.
* A deleted page is not necessarily gone forever: an undo can restore it, together with its blocks.

## Example [#example]

```tsx
import { usePageCount, usePageDelete } from '@sdk-pdf/react'

function DeleteCurrentPageButton({ currentPageId }: { currentPageId: string }) {
  const deletePages = usePageDelete()
  const pageCount = usePageCount()

  return (
    // Keep at least one page in the document.
    <button disabled={pageCount <= 1} onClick={() => deletePages(currentPageId)}>
      Delete page
    </button>
  )
}
```

