Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ export class Clerk implements ClerkInterface {
// Notify other tabs that user is signing out and clean up cookies.
eventBus.emit(events.UserSignOut, null);

if (typeof window !== 'undefined' && (window as any).__clerkClearFetchCache) {
(window as any).__clerkClearFetchCache();
}

this.#setTransitiveState();

await tracker.track(async () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/clerk-js/src/ui/hooks/useFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export const clearFetchCache = () => {
requestCache = new Map<string, State>();
};

/**
* Global function to clear the fetch cache.
* This is exposed on the window object to allow core modules to clear the cache
* without importing from UI modules.
*/
Comment on lines +34 to +38
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like this solution long term, but for now it does the job

if (typeof window !== 'undefined') {
(window as any).__clerkClearFetchCache = clearFetchCache;
}

const serialize = (key: unknown) => (typeof key === 'string' ? key : JSON.stringify(key));

const useCache = <K = any, V = any>(
Expand Down