Pagination

From Esposter/Esposter · View interactive version

Pagination is an AI agent skill from the GitHub repository Esposter/Esposter. Apply when building or reviewing a paginated list, an infinite-scroll feed, a search-as-you-type input, or an offline list cache. Esposter's paginated lists, search-as-you-type inputs and offline list cache.

How to use this skill

Skill file

Pagination, Search & Offline List Cache

The Server and the Wire — one keyset primitive

Every read takes createPageInputSchema(sort), or createSortedPageInputSchema where it offers named orders, over a PageSort it declares beside its input, and answers Page ({ items, nextCursor }, plus count on a first page whose surface shows a total); the server pages with createPageSort, getPageWhere, getPageOrderBy and toPage, and a read merging several sources with toMergedPage. The wire, the cursor and why no client chooses an order are openspec/specs/architecture/pagination/design.md.

Cursor Pagination — Store + Composable + Waypoint

Every paginated list is three layers — a store on useCursorPaginationData (per-key lists on useCursorPaginationDataMap), a useRead* composable wrapping readItems/readMoreItems, and a component with <StyledWaypoint> — never a raw array or a component calling the read; an SSR'd list passes an AsyncDataKey, and a keyed write names its key where it is issued (references/cursor-pagination.md).

StyledWaypoint — Infinite Scroll

<StyledWaypoint> loads the next page, never a Load-more button with a flag of its own; its observer is never torn down, and a default slot replaces its loader entirely (references/cursor-pagination.md).

Search-as-you-type — never hand-rolled

A server search goes through useAutoSearch, or useCursorSearcher for paginated results; data already loaded is searched with MiniSearch in a computed, never a hand-rolled index (references/search-as-you-type.md, openspec/specs/architecture/search/design.md).

Bundle Ancillary Reads with the Primary Read

An ancillary read — permissions, metadata — belongs inside the primary read composable, batched over the page's ids, never in the component's onMounted (references/ancillary-reads.md).

Totals Over the List

A total over the list is the server's, answered on the list's first page, never a computed over the loaded rows — and a write that changes it re-reads it rather than moving it. A keyed read's query closure never runs on the hydrating client, so it writes store state and nothing else. Both: references/list-totals.md.

Re-reads After a Push

A re-read after a push is the store's, which snapshots the server half, pairs the timestamp watermark with the ids it already holds, and queues overlapping re-reads under one executeMutation key: references/push-rereads.md.

Offline IndexedDB cache — self-contained

Nothing outside usePaginationCache touches the cache — no read composable calls useOnline, readIndexedDb or writeIndexedDb, and readItems takes no cache option (references/offline-cache.md).

Deep Dives

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.