Skip to main content
The useUsageEvents hook lists usage events for a single feature using your backend route. By default it calls GET /api/priceos/v1/usage-events and requests the current period.
Setup first: see the React integration guide.

Parameters

string
required
Feature key to list events for (typed to your tracked limit feature keys when using generated types).
boolean
Enable or disable fetching. Defaults to true.
"current" | "previous"
Usage period to query. Defaults to "current". Ignored when customRange is provided.
{ start: number; end: number }
Optional custom Unix-ms range. start and end are required when provided.
number
Page size. Defaults to 20. Allowed range is 1 to 1000.
SWRInfiniteConfiguration<ListUsageEventsResponse, Error>
Optional SWR Infinite config for pagination/revalidation behavior.

Returns

UsageEvent[]
Flattened list of fetched usage events.
boolean
Whether the first page is loading.
boolean
Whether getMore() is currently loading the next page.
boolean
Whether more events are available.
number
Total event count for the current query.
Error | null
Error from the latest request.
() => Promise<void>
Loads the next page when available.
() => Promise<void>
Revalidates loaded pages.

Example