diff --git a/packages/expo/src/singleton.ts b/packages/expo/src/singleton.ts index a5962113c4..fc27b5f06a 100644 --- a/packages/expo/src/singleton.ts +++ b/packages/expo/src/singleton.ts @@ -25,12 +25,17 @@ export function buildClerk({ frontendApi, tokenCache, }: BuildClerkOptions): ClerkProp { - const getToken = tokenCache ? tokenCache.getToken : getTokenFromMemory; - const saveToken = tokenCache ? tokenCache.saveToken : saveTokenInMemory; + const getToken = (tokenCache && tokenCache.getToken) ?? getTokenFromMemory; + const saveToken = (tokenCache && tokenCache.saveToken) ?? saveTokenInMemory; if (!clerk) { clerk = new Clerk(frontendApi); + if (!tokenCache) { + // Exit early if tokenCache is not provided, assuming web platform + return; + } + // @ts-expect-error clerk.__unstable__onBeforeRequest(async (requestInit: FapiRequestInit) => { // https://reactnative.dev/docs/0.61/network#known-issues-with-fetch-and-cookie-based-authentication