Advanced usage
Last updated
Last updated
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-query UseQueryOptions / UseInfiniteQueryOptions
object as the last argument. It also returns all properties returned from react-query extended with some directly accessible entities like tracks
, artist
, etc ().
There is setSpinampClientOptions
function exposed, which allows to set some defaults on QueryClient
instance ().
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 using spinampQueryClient
with persistQueryClient
function ().
If you are using react-query in your app already, and you would like to keep spinamp-hooks
data under the same QueryClient
as the rest of the app, there is an option to do that in three steps:
Remove SpinampProvider
component wrapper, so there is only one QueryClientProvider
.
Set contextSharing
prop on your QueryClientProvider
to true
.
Call enableCustomSpinampProvider()
from spinamp-hooks
at the root of your app. It's needed to disable using internal context in spinamp-hooks
and switch it to the default one.