diff --git a/.changeset/six-carrots-type.md b/.changeset/six-carrots-type.md new file mode 100644 index 00000000000..7cc89aafbcc --- /dev/null +++ b/.changeset/six-carrots-type.md @@ -0,0 +1,7 @@ +--- +'@clerk/clerk-js': minor +'@clerk/clerk-react': minor +'@clerk/types': minor +--- + +Deprecate `Clerk.isReady()` in favor of `Clerk.loaded` diff --git a/packages/clerk-js/src/core/clerk.ts b/packages/clerk-js/src/core/clerk.ts index d32f70291d7..258f55211b2 100644 --- a/packages/clerk-js/src/core/clerk.ts +++ b/packages/clerk-js/src/core/clerk.ts @@ -19,8 +19,8 @@ import type { AuthenticateWithMetamaskParams, BeforeEmitCallback, BuildUrlWithAuthParams, - Clerk as ClerkInterface, ClerkAPIError, + Clerk as ClerkInterface, ClerkOptions, ClientResource, CreateOrganizationParams, @@ -173,7 +173,7 @@ export default class Clerk implements ClerkInterface { #environment?: EnvironmentResource | null; #fapiClient: FapiClient; #instanceType: InstanceType; - #isReady = false; + #loaded = false; /** * @deprecated Although this being a private field, this is a reminder to drop it with the next major release @@ -200,7 +200,7 @@ export default class Clerk implements ClerkInterface { } get loaded(): boolean { - return this.#isReady; + return this.#loaded; } get isSatellite(): boolean { @@ -319,10 +319,13 @@ export default class Clerk implements ClerkInterface { public getFapiClient = (): FapiClient => this.#fapiClient; - public isReady = (): boolean => this.#isReady; + public isReady = (): boolean => { + deprecated('Clerk.isReady()', 'Use `Clerk.loaded` instead.'); + return this.#loaded; + }; public load = async (options?: ClerkOptions): Promise => { - if (this.#isReady) { + if (this.#loaded) { return; } @@ -332,9 +335,9 @@ export default class Clerk implements ClerkInterface { }; if (this.#options.standardBrowser) { - this.#isReady = await this.#loadInStandardBrowser(); + this.#loaded = await this.#loadInStandardBrowser(); } else { - this.#isReady = await this.#loadInNonStandardBrowser(); + this.#loaded = await this.#loadInNonStandardBrowser(); } }; @@ -949,7 +952,7 @@ export default class Clerk implements ClerkInterface { params: HandleOAuthCallbackParams = {}, customNavigate?: (to: string) => Promise, ): Promise => { - if (!this.#isReady || !this.#environment || !this.client) { + if (!this.loaded || !this.#environment || !this.client) { return; } const { signIn, signUp } = this.client; @@ -1619,7 +1622,7 @@ export default class Clerk implements ClerkInterface { }; #buildUrl = (key: 'signInUrl' | 'signUpUrl', options?: SignInRedirectOptions | SignUpRedirectOptions): string => { - if (!this.#isReady || !this.#environment || !this.#environment.displayConfig) { + if (!this.loaded || !this.#environment || !this.#environment.displayConfig) { return ''; } diff --git a/packages/react/src/isomorphicClerk.ts b/packages/react/src/isomorphicClerk.ts index bdfd1748306..ad906323009 100644 --- a/packages/react/src/isomorphicClerk.ts +++ b/packages/react/src/isomorphicClerk.ts @@ -363,7 +363,7 @@ export default class IsomorphicClerk implements IsomorphicLoadedClerk { // Otherwise use the instantiated Clerk object c = this.Clerk; - if (!c.isReady()) { + if (!c.loaded) { await c.load(this.options); } } @@ -390,7 +390,7 @@ export default class IsomorphicClerk implements IsomorphicLoadedClerk { global.Clerk.sdkMetadata = this.options.sdkMetadata ?? { name: PACKAGE_NAME, version: PACKAGE_VERSION }; - if (global.Clerk?.loaded || global.Clerk?.isReady()) { + if (global.Clerk?.loaded) { return this.hydrateClerkJS(global.Clerk); } return; diff --git a/packages/types/src/clerk.ts b/packages/types/src/clerk.ts index 6f9ed2c4069..206d7f4f99e 100644 --- a/packages/types/src/clerk.ts +++ b/packages/types/src/clerk.ts @@ -411,7 +411,7 @@ export interface Clerk { * {@link Clerk.client.signIn.authenticateWithRedirect} or {@link Clerk.client.signUp.authenticateWithRedirect} */ handleRedirectCallback: ( - params: HandleOAuthCallbackParams | HandleSamlCallbackParams, + params: HandleOAuthCallbackParams, customNavigate?: (to: string) => Promise, ) => Promise; @@ -459,6 +459,7 @@ export interface Clerk { /** * Returns true if bootstrapping with Clerk.load has completed successfully. Otherwise, returns false. + * @deprecated Use `loaded` instead. */ isReady: () => boolean; }