Reference / @open-music-sdk/react / useMusicUserToken
Function: useMusicUserToken()
function useMusicUserToken(): readonly [string | undefined, (token) => void];Defined in: integrations/react/src/client.ts:110
The listener's token as the provider holds it, and the function that sets it: with a token, after your own sign-in or an authenticated fetch of one your server stored; with undefined, to forget it, as after a UserTokenInvalid. The setter throws a TypeError for a value that is no token: printable characters with no spaces or line breaks inside.
Forgetting the token here is not a sign-out. The provider then takes no token Apple's script restores until the next connect(), but the script restores it on the next page load; disconnect() from useConnect is the sign-out. The provider does not forget a token on a UserTokenInvalid by itself: the component that made the call gets the error.
Returns
readonly [string | undefined, (token) => void]
The token, or undefined while none is held, and the setter, which keeps its identity.
Throws
TypeError if there is no MusicProvider above the component.