Optionaloptions: UseFetchOptionsconst {
data, fetchNextPage, hasNextPage, isFetchingNextPage,
fetchPreviousPage, hasPreviousPage,
} = useInfiniteDonations(
{ charityType: "tiltify", campaignId },
{ maxPages: 5, initialData: seededPages },
);
useEffect(() => {
if (hasNextPage && !isFetchingNextPage) void fetchNextPage();
}, [hasNextPage, isFetchingNextPage, fetchNextPage]);
Cursor-aware paginated donations hook over TanStack's
useInfiniteQuery. Tiltify uses an opaque string cursor; Twitch uses a numeric page index — the hook dispatches to the matching platform-specific fetcher and normalizes thegetNext/getPreviouspage params across both shapes.Twitch charity donations don't expose a reverse cursor, so
getPreviousPageParamshort-circuits toundefinedon that path (hasPreviousPageis permanentlyfalsefor Twitch).Options (all optional) are forwarded to TanStack:
maxPages— cap on retained pages; drops the oldest when reached.initialData— pre-fetched pages; skips the initial loading state.staleTime/refetchInterval/retry/retryDelay— pass through the standard UseFetchOptions knobs.cachingEnabled— partitions the query cache; useful when the same campaign is fetched with and without cache-busting query params.