Advanced usage
The main goal of this SDK is to provide simple, zero-config hooks API to make interaction with spinamp database quick and easy. However, there are several possibilities to take more control and configure it with the same freedom, as by using react-query directly.
Every
use[Whatever]Query
hook exposed from this library takes react-queryUseQueryOptions / UseInfiniteQueryOptions
object as the last argument. It also returns all properties returned from react-query extended with some directly accessible entities liketracks
,artist
, etc (https://tanstack.com/query/v4/docs/reference/useQuery).There is
setSpinampClientOptions
function exposed, which allows to set some defaults onQueryClient
instance (https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientsetdefaultoptions).If it's not enough, you can import
spinampQueryClient
directly and do whatever is possible with react-query API. For example, you can make your cache persistent by usingspinampQueryClient
withpersistQueryClient
function (https://tanstack.com/query/v4/docs/plugins/persistQueryClient).If you are using react-query in your app already, and you would like to keep
spinamp-hooks
data under the sameQueryClient
as the rest of the app, there is an option to do that in three steps:Remove
SpinampProvider
component wrapper, so there is only oneQueryClientProvider
.Set
contextSharing
prop on yourQueryClientProvider
totrue
.Call
enableCustomSpinampProvider()
fromspinamp-hooks
at the root of your app. It's needed to disable using internal context inspinamp-hooks
and switch it to the default one.
Last updated