Skip to main content

usePageParams

usePageParams reads page and size from the current URL (via React Router’s useSearchParams) and returns a small object you can pass directly into useData/useTypedData to populate page and size query parameters. Source: src/api/usePageParams.ts

Signature

Behavior

  • Reads page and size from the URL.
  • Supports namespacing multiple paginators on a page via prefix:
    • With prefix: 'comments' it reads page_comments and size_comments.
  • Defaults:
    • page defaults to 1
    • size defaults to defaultSize (if provided) or 25
  • Exposes paginationProperties, a readonly list of field names to include in shapes when working with ApiListResult<T> responses.

Examples

Basic list with paging

With shapes for paginated responses

Multiple independent paginators

Notes

  • usePageParams only reads params; updating page/size is done via useSearchParams or Link navigation.
  • The hook is UI-agnostic and doesn’t render anything; it’s safe to use anywhere.

See also