Skip to main content
Requires the entities bundle. A project without the entities bundle returns 403 database/tables-not-available. See Bundles.

Overview

useFetchManyEntitiesWrapper is a stateful wrapper around useFetchManyEntities that manages pagination, sorting, and list state for you. Use it for a self-contained entity feed kept in component state rather than in a shared, listId-keyed useEntityList list — for example, a user profile feed, a filtered search results page, or any custom list with infinite scroll. All filters and sort options mirror those of useFetchManyEntities. Changing any sort option automatically resets the list and re-fetches from page 1.

Usage Example

Parameters

number
Number of entities per page: a whole number from 1 to 100. Defaults to 10. A larger value is rejected with 400 entity/invalid-query, never lowered to 100.
string | null
Filter to entities created by a specific user.
string | "none" | null
Only entities from this source, or "none" for entities with no source. Left out or null: any source.
string | "none" | null
Only entities in this space, or "none" for entities in no space. Left out or null: any space, or none.
boolean
If true, return only entities from users the authenticated user follows.
EntityIncludeParam
Populate related fields, as a single value or an array. Accepted values: "user", "space", "topComments", "saved", "files", "grants".
number
With "topComments" included: how many top comments per entity. Server default 1, maximum 5. Not sent when include doesn’t contain "topComments".
ReactionType
With "topComments" included: the reaction whose raw count ranks the top comments. Server default "upvote". Not sent when include doesn’t contain "topComments".
EntityListSortByOptions
Initial sort field. Default: "createdAt".
SortByReaction
Initial reaction type top ranks by. Only sent while sortBy is "top". Default: "upvote".
"asc" | "desc"
Initial sort direction. Default: "desc"; ignored (not sent) for "hot" and "controversial", which rank one way only.
SortType
Initial sort algorithm. Options: "auto", "numeric", "text", "boolean", "timestamp". Used when sorting by a metadata field. Default: "auto".
TimeFrame | null
Filter entities to a time window. Options: "day", "week", "month", "year".
KeywordsFilters | null
Filter by keywords. See Entity List Filters.
TitleFilters | null
Filter by title content. See Entity List Filters.
ContentFilters | null
Filter by body content. See Entity List Filters.
AttachmentsFilters | null
Filter by attachments data. See Entity List Filters.
LocationFilters | null
Filter by geographic proximity. See Entity List Filters.
MetadataFilters | null
Filter by metadata fields. See Entity List Filters.

Returns

Entity[]
The current list of fetched entities. Appended to on each loadMore call.
boolean
true while fetching the initial page or loading more.
SublayError | null
The last load failure, or null. Cleared when the next load starts; loadMore() retries it. A SublayError.
boolean
true while loadMore() has something to fetch: a next page, or a load that failed.
EntityListSortByOptions
Current sort field.
SortByReaction
Current reaction type top ranks by. Only sent while sortBy is "top".
"asc" | "desc"
Current sort direction.
SortType
Current sort algorithm.
(sortBy: EntityListSortByOptions) => void
Change the sort field. Resets the list and re-fetches from page 1.
(sortByReaction: SortByReaction) => void
Change the reaction type for reaction-based sorting. Resets and re-fetches.
(sortDir: 'asc' | 'desc') => void
Change the sort direction. Resets the list and re-fetches from page 1.
(sortType: SortType) => void
Change the sort algorithm. Resets the list and re-fetches from page 1.
() => Promise<void>
Load the next page of entities and append it, or retry the load that failed. Does nothing while a load is running or when there is nothing more. Never rejects: a failure lands in error.
() => Promise<void>
Reload from the first page with the current filters and sort. The loaded entities stay until the new first page replaces them. Never rejects: a failure lands in error.