# usePagination
> Generates a page number range with ellipsis for pagination controls.

Generates an array of page numbers with ellipsis placeholders for use with [Pagination component](https://next.wave-design-system.pages.dev/components/pagination.md). Supports configurable sibling count around the current page.

## Import

```js
import { usePagination } from '@volue/wave-react';
```

## Example

```jsx
() => {
  const [currentPage, setCurrentPage] = React.useState(5);
  const pageCount = 10;
  const pages = usePagination({ pageCount, currentPage, siblingCount: 1 });

  return (
    <Pagination.Root as={Flex} gap="spacingS" label="Pagination navigation">
      <Pagination.Arrow
        label="Go to previous page"
        direction="back"
        onClick={() => setCurrentPage(page => Math.max(page - 1, 1))}
        isDisabled={currentPage === 1}
      />
      <Pagination.Numbers>
        {pages.map((page, i) =>
          page < 0 ? (
            <Pagination.Ellipsis key={`dots-${i}`} label="Collapsed pages" />
          ) : (
            <Pagination.Number
              key={page}
              label={`Go to page ${page}`}
              isCurrent={page === currentPage}
              onClick={() => setCurrentPage(page)}
            >
              {page}
            </Pagination.Number>
          )
        )}
      </Pagination.Numbers>
      <Pagination.Arrow
        label="Go to next page"
        direction="forward"
        onClick={() => setCurrentPage(page => Math.min(page + 1, pageCount))}
        isDisabled={currentPage === pageCount}
      />
    </Pagination.Root>
  );
};
```

---

## API reference

### Arguments

| Name           | Type     | Default | Description                                                      | Required |
| -------------- | -------- | ------- | ---------------------------------------------------------------- | -------- |
| `pageCount`    | `number` | `—`     | Total number of pages.                                           | Yes      |
| `currentPage`  | `number` | `—`     | The currently selected page number.                              | Yes      |
| `siblingCount` | `number` | `1`     | Number of page numbers to show on each side of the current page. |          |

### Returns

`number[]` — An array of page numbers where `-1` represents an ellipsis.
