Usage Overview
How to use Royco SDK in your application
Provider
Under the hood, it's a wrapper around our Supabase client (for fetching data) and React Query (for caching it on client-side). In order to use Royco SDK, you need to wrap your application with RoycoProvider and provide two values -- originUrl
and originKey
, which are the URL and API key of your Royco Protocol instance respectively. It also takes an optional defaultOptions
prop which can be used to configure the default options for React Query Provider.
RoycoProvider Props
Prop | Type | Default |
---|---|---|
originUrl | string | - |
originKey | string | - |
defaultOptions | DefaultOptions | Refer below |
DefaultOptions type can be imported from @tanstack/react-query (if needed).
Default Options for React Query Provider
Prop | Type | Default |
---|---|---|
refetchOnReconnect | boolean | true |
refetchOnWindowFocus | boolean | false |
retry | number | 3 |
retryDelay | number | 1000 |
refetchIntervalInBackground | boolean | true |
Hooks
These are used to fetch relevant data and interact with Royco Protocol. They take care of caching and invalidating data on client-side using React Query. Hooks are available for most of the common operations like fetching pools, fetching tokens, fetching user data, etc.
Queries
These are your entry point into our managed data endpoints. They are used to fetch data from Royco Protocol and are used internally by hooks. You can also use them directly to fetch data without caching. Queries return the type options provided to useQuery from React Query.
You can use these queryOptions in 2 ways:
Pass Pre-Configured Query Options
Pass them directly to useQuery and build your own custom hooks
Customize Query Options by Destructuring
Destrucutre the correponding object and only use a subset of them by overriding the default options
Last updated on