# usePageCount

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



Returns the number of pages and re-renders the component only when it changes. Prefer it over [usePages](https://sdk.pdf.net/docs/v1/reference/usePages) when only the count matters: it doesn't re-render on page rearrangement, resizing, or rotation.

```ts
const pageCount = usePageCount()
```

Returns `0` while no document is loaded.

## Example [#example]

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

function PageCountBadge() {
  const pageCount = usePageCount()
  return <span>{pageCount} pages</span>
}
```

