Skip to content

Commit

Permalink
feat(clerk-js): Enable BroadcastChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Nov 9, 2023
1 parent e0e79b4 commit 1601f5d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { LocalStorageBroadcastChannel } from '@clerk/shared';
import {
addClerkPrefix,
deprecated,
Expand All @@ -9,6 +8,7 @@ import {
isLegacyFrontendApiKey,
isValidBrowserOnline,
isValidProxyUrl,
LocalStorageBroadcastChannel,
noop,
parsePublishableKey,
proxyUrlToAbsoluteURL,
Expand Down Expand Up @@ -1437,6 +1437,7 @@ export default class Clerk implements ClerkInterface {

const isInAccountsHostedPages = isDevAccountPortalOrigin(window?.location.hostname);

this.#broadcastChannel = new LocalStorageBroadcastChannel('clerk');
this.#setupListeners();

let retries = 0;
Expand Down Expand Up @@ -1530,7 +1531,7 @@ export default class Clerk implements ClerkInterface {

this.#broadcastChannel?.addEventListener('message', ({ data }) => {
if (data.type === 'signout') {
void this.handleUnauthenticated({ broadcast: false });
void this.handleUnauthenticated({ broadcast: true });
}
});
};
Expand Down

0 comments on commit 1601f5d

Please sign in to comment.