dolfindevelopers
@dolfinai/react

useBills

The SDK includes hooks and connected components. Hooks can also be used independently with your own interface. This example lists bills with useBills, handling loading, errors and pagination.

Terminal
bun add @dolfinai/react

No registry token or shadcn setup needed. Hooks must run inside DolfinProvider: set that up first if you have not.

List bills

my-bills.tsx
import { useBills } from "@dolfinai/react/ap";

// Render inside your connected DolfinProvider.
export function MyBills() {
  const { bills, isLoading, error, refetch, hasNextPage, nextPage } =
    useBills({ pageSize: 10 });

  if (isLoading) return <p>Loading bills…</p>;
  if (error) return <button onClick={refetch}>Try again</button>;
  if (!bills?.length) return <p>No bills yet.</p>;

  return (
    <section>
      <ul>{bills.map(bill => (
        <li key={bill.id}>{bill.supplierName}: {bill.invoiceNumber}</li>
      ))}</ul>
      <button disabled={!hasNextPage} onClick={nextPage}>Next page</button>
    </section>
  );
}

Options

OptionBehavior
pageSize10 by default, clamped between 1 and 100.
filtersBillListFilters. Changing applied filters resets pagination.
debounceMsText filters wait 400 ms by default.
enabledSet false to disable fetching.

The result includes bills, loading/error state, refetch, and cursor-backed pagination. The hook keeps previous data visible while a new page loads.

DO NOT WANT TO WRITE THE MARKUP?

The Bills table component does this for you