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.
bun add @dolfinai/reactNo registry token or shadcn setup needed. Hooks must run inside DolfinProvider: set that up first if you have not.
List bills
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
| Option | Behavior |
|---|---|
pageSize | 10 by default, clamped between 1 and 100. |
filters | BillListFilters. Changing applied filters resets pagination. |
debounceMs | Text filters wait 400 ms by default. |
enabled | Set 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?