Appearance
Documentation / react-auth / PrivyEvents
Interface: PrivyEvents
Properties
accessToken
accessToken:
Object
Type declaration
onAccessTokenGranted
onAccessTokenGranted: (
params
) =>void
Callback that will execute when a user's access token is granted.
Parameters
• params: Object
• params.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: (
params
) =>void
Callback that will execute when MFA is required to complete a given action.
Parameters
• params: Object
• params.mfaMethods: ("sms"
| "totp"
| "passkey"
)[]
[] - List of MFA methods that the user can choose from
Returns
void
connectWallet
connectWallet:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful wallet connection.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>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
• params: Object
• params.wallet: BaseConnectedEthereumWallet
| BaseConnectedSolanaWallet
[BaseConnectedEthereumWallet | BaseConnectedSolanaWallet]([object Object]) the wallet
object correspending to the connection
Returns
void
createWallet
createWallet:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful wallet creation.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>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
• params: Object
• params.wallet: Wallet
BaseConnectedWallet- the created wallet
object
Returns
void
customAuth
customAuth:
Object
Type declaration
onAuthenticated
onAuthenticated: (
params
) =>void
Callback that will execute when Privy successfully exchanges a custom auth JWT for a Privy JWT
Parameters
• params: Object
• params.user: User
The Privy user
Returns
void
onUnauthenticated
onUnauthenticated: () =>
void
Callback that will execute when Privy detects a user is logged out from the third-party auth system, and correspondingly logs the user out.
Returns
void
fundSolanaWallet
fundSolanaWallet:
Object
Type declaration
onUserExited?
onUserExited?: (
params
) =>void
Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
Parameters
• params: Object
• params.address: string
{string} The address of the wallet being funded
• params.balance: undefined
| bigint
{bigint} The value for the funded wallet at the point of user exit.
• params.cluster: SolanaCluster
{SolanaCluster} The Solana cluster of the wallet being funded
• params.fundingMethod: null
| FundingMethod
| "manual"
[FundingMethod]([object Object]) The funding method associated with the flow at time of exit. If the user had not yet selected a recovery method, this will be null.
Returns
void
fundWallet
fundWallet:
Object
Type declaration
onUserExited?
onUserExited?: (
params
) =>void
Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
Parameters
• params: Object
• params.address: string
{string} The address of the wallet being funded
• params.balance: undefined
| bigint
{bigint} The value for the funded wallet at the point of user exit.
• params.chain: Chain
{Chain} The chain of the wallet being funded
• params.fundingMethod: null
| FundingMethod
| "manual"
[FundingMethod]([object Object]) The funding method associated with the flow at time of exit. If the user had not yet selected a recovery method, this will be null.
Returns
void
linkAccount
linkAccount:
Object
Type declaration
onError?
onError?: (
error
,details
) =>void
Callback that will execute in the case of a non-successful account linking.
Parameters
• error: PrivyErrorCode
{PrivyErrorCode} - the corresponding error code
• details: Object
• details.linkMethod: LoginMethod
{LoginMethod} - the type of (attempted) linked account
Returns
void
onSuccess?
onSuccess?: (
params
) =>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
• params: Object
• params.linkMethod: LoginMethod
[LoginMethod]([object Object])- the type of linked account
• params.linkedAccount: LinkedAccountWithMetadata
the newly linked account
• params.user: User
User- the user the account was linked to
Returns
void
login
login:
Object
Type declaration
onComplete?
onComplete?: (
params
) =>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 totrue
.
Parameters
• params: Object
• params.isNewUser: boolean
{boolean} boolean flag indicating if this is the user's first time logging in to your app
• params.loginAccount: null
| LinkedAccountWithMetadata
the account corresponding to the loginMethod used
• params.loginMethod: null
| LoginMethod
{string} - the method used by the user to login
• params.user: User
User the user
oject corresponding to the authenticated user
• params.wasAlreadyAuthenticated: boolean
{boolean} - boolean flag indicating whether the user entered the application already authenticated
Returns
void
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful login.
Parameters
• error: PrivyErrorCode
PrivyErrorCode - the corresponding error code
Returns
void
logout
logout:
Object
Type declaration
onSuccess?
onSuccess?: () =>
void
Callback that will execute when a user successfully logs out.
Returns
void
oAuthAuthorization
oAuthAuthorization:
Object
Type declaration
onOAuthTokenGrant
onOAuthTokenGrant: (
params
) =>void
Callback that will execute when a user successfully authorizes an OAuth flow.
Parameters
• params: Object
• params.oAuthTokens: OAuthTokens
OAuthTokens - the OAuth tokens returned from the OAuth provider:
• params.user: User
User The authenticated user
Returns
void
sendSolanaTransaction
sendSolanaTransaction:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful sendTransaction.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once a successful sendSolanaTransaction
completes. This will not run in the case of a wallet-based authentication or link flow.
Parameters
• params: Object
• params.response: SolanaTransactionReceipt
the response SolanaTransactionReceipt from the successful transaction
Returns
void
sendTransaction
sendTransaction:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful sendTransaction.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once a successful sendTransaction
completes. This will not run for transactions with external wallets.
Parameters
• params: Object
• params.hash: `0x${string}`
Returns
void
setWalletPassword
setWalletPassword:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful setWalletPassword.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once a successful setWalletPassword
completes.
Parameters
• params: Object
• params.wallet: Wallet
Wallet- the wallet
object that the password was set for
Returns
void
setWalletRecovery
setWalletRecovery:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful setWalletRecovery.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once a successful setWalletRecovery
completes.
Parameters
• params: Object
• params.method: UserRecoveryMethod
[UserRecoveryMethod]([object Object]) - the recovery method that was set
• params.wallet: Wallet
Wallet- the wallet object that the recovery was set for
Returns
void
signMessage
signMessage:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful signMessage.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>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
• params: Object
• params.signature: string
the signature (type string) of the embedded wallet used to sign message
Returns
void
signTransaction
signTransaction:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful signTransaction.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once a successful signTransaction
completes. This will not run for transactions with external wallets.
Parameters
• params: Object
• params.signature: `0x${string}`
Returns
void
signTypedData
signTypedData:
Object
Type declaration
onError?
onError?: (
error
) =>void
Callback that will execute in the case of a non-successful signTypedData.
Parameters
• error: PrivyErrorCode
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once a successful signTypedData
completes.
Parameters
• params: Object
• params.signature: string
the signature (type string) of the embedded wallet used to sign
Returns
void
update
update:
Object
Type declaration
onError?
onError?: (
error
,details
) =>void
Callback that will execute in the case of a non-successful account linking.
Parameters
• error: PrivyErrorCode
{PrivyErrorCode} - the corresponding error code
• details: Object
• details.linkMethod: LoginMethod
{LoginMethod} - the type of (attempted) linked account
Returns
void
onSuccess?
onSuccess?: (
params
) =>void
Callback that will execute once on a successful updating of an account. This will run when any of the 'updateAccount' methods are called manually.
Parameters
• params: Object
• params.updateMethod: LoginMethod
[LoginMethod]([object Object])- the type of updated account
• params.updatedAccount: LinkedAccountWithMetadata
the newly updated account
• params.user: User
User- the user the account was linked to
Returns
void