> For the complete documentation index, see [llms.txt](https://pollz.gitbook.io/pollz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pollz.gitbook.io/pollz/tooling/react/usepolls.md).

# usePolls()

## `usePolls`&#x20;

The `usePolls` hook is a custom hook provided by the `pollz-react` package. It allows you to fetch a paginated list of all polls from the Pollz SDK within a React component.

### Parameters

The `usePolls` hook does not take any parameters.

### Return Values

The `usePolls` hook returns an object with the following properties:

* `polls` ({ items: Poll\[]; meta: PaginationMeta }): An object containing the list of polls (`items`) and metadata (`meta`) about the retrieved polls, including total count, current page, items per page, and total number of pages.
* `refetch` (function): A function to manually refetch the list of polls.

### Usage

```jsx
import { usePolls } from 'pollz-react';

const YourComponent = () => {
  const { polls, refetch } = usePolls();

  if (!polls) {
    return <div>Loading...</div>;
  }

  return (
    <div>
      <h2>All Polls</h2>
      {polls.items.map((poll) => (
        <div key={poll.id}>
          <p>{poll.name}</p>
          {/* Render additional poll details */}
        </div>
      ))}
      <button onClick={() => refetch()}>Refetch Polls</button>
    </div>
  );
};
```

The `usePolls` hook simplifies the process of fetching and displaying a paginated list of all polls within your React components. Customize the hook based on your application's needs.

<br>
