Skip to content
Client
Server

Reference / @open-music-sdk/browser / tConnect

Interface: tConnect ​

Defined in: integrations/browser/src/connect.ts:64

The helper. Its functions need no this, so each can be handed on by itself.

Properties ​

connect ​

ts
readonly connect: () => Promise<string | undefined>;

Defined in: integrations/browser/src/connect.ts:81

Opens Apple's sign-in window, to be called inside the listener's click, and resolves to the Music User Token, or to undefined when the listener declines: when the script rejects with its AUTHORIZATION_ERROR, as declining and closing its window both did against the live API, or answers with nothing. Waits on nothing but ready, which is settled by the time there is a button to click. After a ready that failed, the script is loaded and configured afresh, so a page whose endpoint was down when it loaded can still sign in; what that fails with, it rejects with, as ready would. What else the script's authorize() throws is handed on as it came. Called after dispose() it is a TypeError.

Returns ​

Promise<string | undefined>


disconnect ​

ts
readonly disconnect: () => Promise<void>;

Defined in: integrations/browser/src/connect.ts:90

Apple's own sign-out, through the script's unauthorize(): ends the sign-in in the script and the copy of the token it kept, so that a later page load does not restore it. It ends the token at Apple too, and with it any copy your server stored: against the live API on 18 October 2026, Apple refused the token as soon as unauthorize() resolved, and five minutes later. Does nothing where the script has no such function, or where the page holds no configuration. Rejects with what the configuration failed with, or what unauthorize() throws, as it came. Called after dispose() it is a TypeError.

Returns ​

Promise<void>


dispose ​

ts
readonly dispose: () => void;

Defined in: integrations/browser/src/connect.ts:92

Stops keeping the developer token fresh. The script stays: it is the page's.

Returns ​

void


ready ​

ts
readonly ready: Promise<string | undefined>;

Defined in: integrations/browser/src/connect.ts:71

Settles once Apple's script is loaded and configured: with the token the script restored for a returning listener, or with undefined. Rejects with an AppleMusicError tagged NetworkError when the script cannot be loaded, with what the developer-token provider rejects with, DeveloperTokenUnavailable for the client's own, when the token cannot be fetched, and with what Apple's configure throws, as it came.

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.