ReservoirKit comes with powerful hooks to make accessing Reservoir data simple and efficient.

Prerequisites ⚙️

Install and configure ReservoirKit

SWR powered hooks

These hooks use SWR, a performant lightweight data fetching hook library. Using SWR means that we can cache requests, batch requests and use powerful features developed and tested by the SWR team. You can utilize hooks across your components without worrying about performance or duplicate network requests. You can also pass in SWR configuration options to each SWR powered hook. Below are the properties returned in each SWR powered hook.

response: The response returned from the api
data: The data extracted from the response
mutate: SWR's mutate function for refreshing data.
error: An api error
isValidating: If there's an ongoing request or revalidation


Infinite Loading Hooks

The following hooks are built with infinite loading in mind. They expose a some useful methods and properties to build an infinite loading UX, in addition to the properties returned by all SWR powered hooks.

hasNextPage: If there is more data to load
isFetchingInitialData: If the initial data has been fetched or not
isFetchingPage: If data is currently being fetched
fetchNextPage: A method to fetch the next page, takes no parameters.


Utility Hooks

Just like every good tool belt there are usually some utility hooks included. These hooks don't necessarily fetch Reservoir data but they are quite useful.


Did this page help you?