# Pagination · Chromia Docs (concept)

> Each query in FT4 has pagination enabled by default. The query will return a paged result containing the result and the cursor to fetch the next page.

Source: https://docs.chromia.com/build/ft4/pagination/

# Pagination

Each query in FT4 has pagination enabled by default. The query will return a paged result containing the result and the
cursor to fetch the next page.

The pagination system revolves around two key components:

1. **[`page_cursor`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/page_cursor/)**: Points to the position in the data where the next page should begin.
2. **[`paged_result`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/paged_result/)**: Contains the data for the current page and a cursor for fetching the next page.

You can use this utility in queries where paginated results are needed, enabling the front-end to request data page by
page.

### Key functions and structures

* **[`page_cursor`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/page_cursor/)**: A struct that keeps track of the position of the last item retrieved.
* **[`pagination_result`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/pagination_result/)**: Represents a single element of a paginated result containing data of the fetched result and
  the rowid.
* **[`paged_result`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/paged_result/)**: Represents the full response of a paginated query. Contains a list of data and a cursor to fetch
  the next page.
* **[`encode_cursor`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/encode_cursor/) & [`decode_cursor`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/decode_cursor/)**: Functions that encode and decode a [`page_cursor`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/page_cursor/) into a Base64 string for
  easier management.
* **[`fetch_data_size`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/fetch_data_size/)**: Determines the page size based on the request and module configuration.
* **[`make_page`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/make_page/)**: Creates a paginated response from a list of data, and ensures the page size is respected.
* **[`before_rowid`](https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.utils/before_rowid/)**: Retrieves the `rowid` of the last retrieved element from the cursor, used to determine where the
  next page should start.

[View this page on docs.chromia.com](https://docs.chromia.com/build/ft4/pagination/)Content mirrored from the live docs
