From 6ff04fdbd99f52894ea1a3ec43fa036f47fab21f Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Tue, 9 Jul 2024 15:22:24 +0300 Subject: [PATCH] fix(expo): Handle authentication completion from popup on Web --- packages/expo/src/provider/ClerkProvider.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/expo/src/provider/ClerkProvider.tsx b/packages/expo/src/provider/ClerkProvider.tsx index b5d390eb43..1ff7dbdc14 100644 --- a/packages/expo/src/provider/ClerkProvider.tsx +++ b/packages/expo/src/provider/ClerkProvider.tsx @@ -1,9 +1,10 @@ import '../polyfills'; import { ClerkProvider as ClerkReactProvider } from '@clerk/clerk-react'; +import * as WebBrowser from 'expo-web-browser'; import type { TokenCache } from '../caches/types'; -import { isNative } from '../utils/runtime'; +import { isNative, isWeb } from '../utils/runtime'; import { getClerkInstance } from './singleton'; export type ClerkProviderProps = React.ComponentProps & { @@ -19,6 +20,11 @@ export function ClerkProvider(props: ClerkProviderProps): JSX.Element { const { children, tokenCache, publishableKey, ...rest } = props; const pk = publishableKey || process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY || process.env.CLERK_PUBLISHABLE_KEY || ''; + if (isWeb()) { + // This is needed in order for useOAuth to work correctly on web. + WebBrowser.maybeCompleteAuthSession(); + } + return (