Skip to main content

Overview

useFetchManyEvents returns a callable that fetches a single page of events with all filters, sorting, geo, and free-text search. Visibility is enforced server-side. This is the low-level query — for a stateful list with sort state and load-more, use useFetchManyEventsWrapper.

Usage Example

import { useFetchManyEvents } from "@sublay/react-js";

function useUpcoming() {
  const fetchManyEvents = useFetchManyEvents();
  return () =>
    fetchManyEvents({
      timeWindow: "upcoming",
      sortBy: "startTime",
      type: "physical",
      page: 1,
      limit: 20,
      include: ["userRsvp"],
    });
}

Parameters

page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Capped at 100.
sortBy
"startTime" | "going"
Sort field. Defaults to "startTime".
sortDir
"asc" | "desc"
Sort direction. Defaults to "asc".
timeWindow
"upcoming" | "ongoing" | "past"
Derived time window.
startsAfter
string
ISO datetime lower bound on startTime.
startsBefore
string
ISO datetime upper bound on startTime.
spaceId
string
Restrict to one space.
hostId
string
Only events this user hosts.
type
"online" | "physical" | "hybrid"
Filter by type.
status
"active" | "cancelled"
Defaults to "active".
myRsvp
RsvpStatus | RsvpStatus[]
Statuses the logged-in user RSVP’d with, e.g. ["going","maybe"].
locationFilters
{ latitude; longitude; radius }
Proximity filter (radius in meters).
titleFilters
{ hasTitle?; includes?; doesNotInclude? }
Free-text filter on title.
descriptionFilters
{ hasDescription?; includes?; doesNotInclude? }
Free-text filter on description.
include
string | string[]
Associations to expand.

Returns

Returns a Promise<PaginatedResponse<Event>>{ data, pagination }.

See Also