Skip to content

Documentation / expo / useLoginWithOAuth

Function: useLoginWithOAuth()

useLoginWithOAuth(opts?): Object

Returns a login function to initiate an oauth login flow, as well as the current state of oauth flow

Parameters

opts?: OAuthHookOptions

Returns

Object

login

login: (__namedParameters) => Promise<undefined | PrivyUser> = start

Launch a web browser to login with an external OAuth account

Parameters

__namedParameters: StartOAuthFlowArgs

Returns

Promise<undefined | PrivyUser>

Example

ts
<Button onPress={() => login({ provider: 'google' })} />

state

state: OAuthFlowState

Example

ts
// Somewhere within a component tree wrapped with <PrivyProvider />
const {login, state} = useLoginWithOAuth()

// Kick off an oauth flow
<Button onPress={() => login({ provider: 'google' })} /> *

// Show a spinner during the transition
{state.status === 'loading' && <Spinner />}