Skip to content

Commit

Permalink
fix(expo): Handle authentication completion from popup on Web
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Jul 9, 2024
1 parent a3c6a5f commit 6ff04fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/expo/src/provider/ClerkProvider.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof ClerkReactProvider> & {
Expand All @@ -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 (
<ClerkReactProvider
// Force reset the state when the provided key changes, this ensures that the provider does not retain stale state.
Expand Down

0 comments on commit 6ff04fd

Please sign in to comment.