Dev Helpers

TypeScript / Typed pagination

Check for another page

Dev Helpers · April 22, 2026

Pagination state needs a reliable signal for the final page. A missing cursor and an empty result are different conditions.

Worked example

type Page<T> = { items: T[]; next: string | null };
const page: Page<{ id: number }> = { items: [{ id: 1 }, { id: 2 }], next: "2" };
console.log(page.next !== null);

Result

true

Implementation notes

Cursor pagination may return fewer records than requested and still offer another page. Prefer the API's explicit continuation token.

Try it yourself

Check a full final page and a short page that still carries a next cursor.

Open the TypeScript example →

Editorial date April 22, 2026 · Published December 6, 2026

Related articles

Reject fractional cent amounts

A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.

Infer route names from a registry

A route registry can drive both lookup and allowed route names. Type the keys from the registry so a removed route cannot survive in a separate union.