Skip to content

Documentation / react-auth / PrivyEvents

Interface: PrivyEvents

Properties

accessToken

accessToken: Object

Type declaration

onAccessTokenGranted

onAccessTokenGranted: (accessToken) => void

Callback that will execute when a user's access token is granted.

Parameters

accessToken: string

The user's access token

Returns

void

onAccessTokenRemoved

onAccessTokenRemoved: () => void

Callback that will execute when a user's access token is removed.

Returns

void


configureMfa

configureMfa: Object

Type declaration

onMfaRequired

onMfaRequired: (mfaMethods) => void

Callback that will execute when MFA is required to complete a given action.

Parameters

mfaMethods: ("sms" | "totp" | "passkey")[]

[] - List of MFA methods that the user can choose from

Returns

void


connectWallet

connectWallet: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful wallet connection.

Param

[PrivyErrorCode]([object Object]) - the corresponding error code

onSuccess?

onSuccess?: (wallet) => void

Callback that will execute once a successful connectWallet completes. This will not run in the case of a wallet-based authentication or link flow.

Parameters

wallet: BaseConnectedWallet

[BaseConnectedWallet]([object Object]) the wallet object correspending to the connection

Returns

void


createWallet

createWallet: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful wallet creation.

Param

[PrivyErrorCode]([object Object]) - the corresponding error code

onSuccess?

onSuccess?: (wallet) => void

Callback that will execute once on a successful embedded wallet creation. This will run when createWallet is called manually, or when config.embeddedWallets.createOnLogin triggers an automatic wallet creation.

Parameters

wallet: Wallet

[BaseConnectedWallet]([object Object])- the created wallet object

Returns

void


linkAccount

linkAccount: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful account linking.

Param

{PrivyErrorCode} - the corresponding error code

onSuccess?

onSuccess?: (user, linkMethod, linkedAccount) => void

Callback that will execute once on a successful linking of a new account/login method. This will run when any of the 'link' methods are called manually.

Parameters

user: User

User- the user the account was linked to

linkMethod: LoginMethod

[LoginMethod]([object Object])- the type of linked account

linkedAccount: LinkedAccountWithMetadata

the newly linked account

Returns

void


login

login: Object

Type declaration

onComplete?

onComplete?: (user, isNewUser, wasAlreadyAuthenticated, loginMethod, loginAccount) => void

Callback that will execute once a login flow successfully completes.

  • If config.embeddedWallets.createOnLogin is set to 'off' or a wallet creation flow is not applicable, this will run after the user successfully authenticates.
  • If config.embeddedWallets.createOnLogin is set to 'users-without-wallets' or 'all-users', this will run after the user successfully authenticates and creates their wallet (if applicable).
  • If a user is already authenticated, this will run immediately and the wasAlreadyAuthenticated flag will be set to true.
Parameters

user: User

User the user oject corresponding to the authenticated user

isNewUser: boolean

{boolean} boolean flag indicating if this is the user's first time logging in to your app

wasAlreadyAuthenticated: boolean

{boolean} - boolean flag indicating whether the user entered the application already authenticated

loginMethod: null | LoginMethod

{string} - the method used by the user to login

loginAccount: null | LinkedAccountWithMetadata

the account corresponding to the loginMethod used

Returns

void

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful login.

Param

[PrivyErrorCode]([object Object]) - the corresponding error code

onOAuthLoginComplete?

onOAuthLoginComplete?: (oAuthProviderTokens) => void

Callback that will execute once a successful OAuth login flow completes. This will only run in the case of an OAuth login flow.

This will always be called before onComplete in the case of an OAuth login flow. If you will be doing anything after the user is logged in (e.g. sending data to your API or redirecting to an authenticated route), you should wait for onComplete to run.

Parameters

oAuthProviderTokens: OAuthProviderTokens

OAuthProviderTokens - the OAuth tokens returned from the OAuth provider

Returns

void


logout

logout: Object

Type declaration

onSuccess?

onSuccess?: () => void

Callback that will execute when a user successfully logs out.

Returns

void


sendTransaction

sendTransaction: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful sendTransaction.

Param

[PrivyErrorCode]([object Object]) - the corresponding error code

onSuccess?

onSuccess?: (response) => void

Callback that will execute once a successful sendTransaction completes. This will not run in the case of a wallet-based authentication or link flow.

Parameters

response: TransactionResponse

the response (type TransactionResponse https://docs.ethers.org/v5/api/providers/types/#providers-TransactionResponse) from the successful transaction

Returns

void


setWalletPassword

setWalletPassword: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful setWalletPassword.

Param

{PrivyErrorCode} - the corresponding error code

onSuccess?

onSuccess?: (wallet) => void

Callback that will execute once a successful setWalletPassword completes.

Parameters

wallet: Wallet

Wallet- the wallet object that the password was set for

Returns

void


signMessage

signMessage: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful signMessage.

Param

[PrivyErrorCode]([object Object]) - the corresponding error code

onSuccess?

onSuccess?: (signature) => void

Callback that will execute once a successful signMessage completes. This will not run in the case of a wallet-based authentication or link flow.

Parameters

signature: string

the signature (type string) of the embedded wallet used to sign message

Returns

void


signTypedData

signTypedData: Object

Type declaration

onError?

onError?: CallbackError

Callback that will execute in the case of a non-successful signTypedData.

Param

[PrivyErrorCode]([object Object]) - the corresponding error code

onSuccess?

onSuccess?: (signature) => void

Callback that will execute once a successful signTypedData completes.

Parameters

signature: string

the signature (type string) of the embedded wallet used to sign

Returns

void