Interface: PrivyInterface
Allows you to manage the user's current authentication state and access their linked accounts. You can access the fields and methods documented here via the usePrivy hook.
Properties
authenticated
• authenticated: boolean
True if the user is authenticated, false otherwise.
You should always check that ready
is true before using this value. Otherwise,
the value may outdated while the Privy client fetches fresh tokens.
connectWallet
• connectWallet: () => void
Type declaration
▸ (): void
Opens the Privy modal and prompts the user to connect a wallet.
Returns
void
createWallet
• createWallet: () => Promise
<Wallet
>
Type declaration
▸ (): Promise
<Wallet
>
Experimental: This feature is subject to change at any time.
Prompts a user to create an Ethereum wallet through Privy.
This function will fail if the user has already created a wallet through Privy, as Privy currently only supports creating one wallet per user.
This requires a user to enter a recovery pin that can later be used to recover the wallet or port it across devices.
Returns
Promise
<Wallet
>
exportWallet
• exportWallet: () => Promise
<void
>
Type declaration
▸ (): Promise
<void
>
Returns
Promise
<void
>
forkSession
• forkSession: () => Promise
<string
>
Type declaration
▸ (): Promise
<string
>
Experimental: This feature is subject to change at any time.
Get a short-lived, one-time-use token to start a new Privy session from the existing authenticated session. Raises an exception if the current session was already forked from a previous session.
Returns
Promise
<string
>
getAccessToken
• getAccessToken: () => Promise
<null
| string
>
Type declaration
▸ (): Promise
<null
| string
>
Get the Privy access token (JWT) for an authenticated user. Returns null for an unauthenticated user.
You may use this token to authorize requests sent from your frontend, and can validate it in your backend against your app's Privy verification key.
This will automatically attempt to refresh the session if the token is expired or about to expire.
Returns
Promise
<null
| string
>
getEthereumProvider
• getEthereumProvider: () => EIP1193Provider
Type declaration
▸ (): EIP1193Provider
Deprecated
Deprecated: This feature will be removed and should be replaced by interfacing with wallets directly (wallets[0].getEthereumProvider()).
Get an EIP-1193-compatible provider from the user's wallet, if the user has connected one.
You may then use the Ethereum Javascript API syntax to send JSON-RPC requests to the user's wallet.
Returns
getEthersProvider
• getEthersProvider: () => Web3Provider
Type declaration
▸ (): Web3Provider
Deprecated
Deprecated: This feature will be removed and should be replaced by interfacing with wallets directly (wallets[0].getEthersProvider()).
Get an ethers.js-compatible provider from the user's wallet, if the user has connected one.
Returns
Web3Provider
getWeb3jsProvider
• getWeb3jsProvider: () => AbstractProvider
Type declaration
▸ (): AbstractProvider
Deprecated
Deprecated: This feature will be removed and should be replaced by interfacing with wallets directly (wallets[0].getWeb3jsProvider()).
Get a web3.js-compatible provider from the user's wallet, if the user has connected one.
Returns
AbstractProvider
linkApple
• linkApple: () => void
Type declaration
▸ (): void
For users who are authenticated, prompts the user to link Apple OAuth account This will directly initiate the OAuth flow for Apple.
Returns
void
linkDiscord
• linkDiscord: () => void
Type declaration
▸ (): void
For users who are authenticated, prompts the user to link Discord OAuth account This will directly initiate the OAuth flow for Discord.
Returns
void
linkEmail
• linkEmail: () => void
Type declaration
▸ (): void
For users who are authenticated, opens the Privy modal and prompts the user to link an email. This will open the Privy Modal which will guide the user through this action.
Returns
void
linkGithub
• linkGithub: () => void
Type declaration
▸ (): void
For users who are authenticated, prompts the user to link Github OAuth account This will directly initiate the OAuth flow for Github.
Returns
void
linkGoogle
• linkGoogle: () => void
Type declaration
▸ (): void
For users who are authenticated, prompts the user to link a Google OAuth account. This will directly initiate the OAuth flow for Google.
Returns
void
linkPhone
• linkPhone: () => void
Type declaration
▸ (): void
For users who are authenticated, opens the Privy modal and prompts the user to link a phone number. This will open the Privy Modal which will guide the user through this action.
Returns
void
linkTwitter
• linkTwitter: () => void
Type declaration
▸ (): void
For users who are authenticated, prompts the user to link a Twitter OAuth account This will directly initiate the OAuth flow for Twitter.
Returns
void
linkWallet
• linkWallet: () => void
Type declaration
▸ (): void
For users who are authenticated, opens the Privy modal and prompts the user to link a wallet. This will open the Privy Modal which will guide the user through this action.
Returns
void
login
• login: () => void
Type declaration
▸ (): void
Opens the Privy login modal and prompts the user to login.
Returns
void
logout
• logout: () => Promise
<void
>
Type declaration
▸ (): Promise
<void
>
Log the current user out and clears their authentication state. authenticated
will become false, user
will become null, and the Privy Auth tokens will be deleted from the browser's local storage.
You may await this call to take an action once logout is complete (e.g. redirecting to a specific page).
Returns
Promise
<void
>
ready
• ready: boolean
Check whether the PrivyProvider
is ready to be used. You should wait for this to
be true before using values such as authenticated
and user
.
sendTransaction
• sendTransaction: (data
: UnsignedTransactionRequest
, uiOptions?
: SendTransactionModalUIOptions
) => Promise
<TransactionReceipt
>
Type declaration
▸ (data
, uiOptions?
): Promise
<TransactionReceipt
>
Parameters
Name | Type |
---|---|
data | UnsignedTransactionRequest |
uiOptions? | SendTransactionModalUIOptions |
Returns
Promise
<TransactionReceipt
>
setActiveWallet
• setActiveWallet: (address
: string
) => Promise
<void
>
Type declaration
▸ (address
): Promise
<void
>
Deprecated
Deprecated: This feature will be removed and behaves the same as connectWallet(). Instead, please interact with the wallets array directly.
Note that when you connect a new wallet, it becomes first in the wallets array.
Parameters
Name | Type |
---|---|
address | string |
Returns
Promise
<void
>
signMessage
• signMessage: (message
: string
, uiOptions?
: SignMessageModalUIOptions
) => Promise
<string
>
Type declaration
▸ (message
, uiOptions?
): Promise
<string
>
Experimental: This feature is subject to change at any time.
Prompts a user to sign a message using their Privy wallet.
The resulting signature is an EIP-191 personal_sign signature (0x45).
This function currently has a precondition that the user has a Privy wallet. It will fail otherwise.
Parameters
Name | Type |
---|---|
message | string |
uiOptions? | SignMessageModalUIOptions |
Returns
Promise
<string
>
unlinkApple
• unlinkApple: (subject
: string
) => Promise
<User
>
Type declaration
▸ (subject
): Promise
<User
>
Unlink a Apple social account from a user, by passing the apple subject ID. Note that you can only unlink a social account if the user has at least one other account.
Parameters
Name | Type |
---|---|
subject | string |
Returns
Promise
<User
>
unlinkDiscord
• unlinkDiscord: (subject
: string
) => Promise
<User
>
Type declaration
▸ (subject
): Promise
<User
>
Unlink a Discord social account from a user, by passing the discord subject ID. Note that you can only unlink a social account if the user has at least one other account.
Parameters
Name | Type |
---|---|
subject | string |
Returns
Promise
<User
>
unlinkEmail
• unlinkEmail: (address
: string
) => Promise
<User
>
Type declaration
▸ (address
): Promise
<User
>
Unlink an email account from a user, by passing the email address. Note that you can only unlink an email account if the user has at least one other account.
Parameters
Name | Type |
---|---|
address | string |
Returns
Promise
<User
>
unlinkGithub
• unlinkGithub: (subject
: string
) => Promise
<User
>
Type declaration
▸ (subject
): Promise
<User
>
Unlink a Github social account from a user, by passing the github subject ID. Note that you can only unlink a social account if the user has at least one other account.
Parameters
Name | Type |
---|---|
subject | string |
Returns
Promise
<User
>
unlinkGoogle
• unlinkGoogle: (subject
: string
) => Promise
<User
>
Type declaration
▸ (subject
): Promise
<User
>
Unlink a Google social account from a user, by passing the google subject ID. Note that you can only unlink a social account if the user has at least one other account.
Parameters
Name | Type |
---|---|
subject | string |
Returns
Promise
<User
>
unlinkPhone
• unlinkPhone: (phoneNumber
: string
) => Promise
<User
>
Type declaration
▸ (phoneNumber
): Promise
<User
>
Unlink a phone account from a user, by passing the phone number. Note that you can only unlink a phone account if the user has at least one other account.
Parameters
Name | Type |
---|---|
phoneNumber | string |
Returns
Promise
<User
>
unlinkTwitter
• unlinkTwitter: (subject
: string
) => Promise
<User
>
Type declaration
▸ (subject
): Promise
<User
>
Unlink a Twitter social account from a user, by passing the twitter subject ID. Note that you can only unlink a social account if the user has at least one other account.
Parameters
Name | Type |
---|---|
subject | string |
Returns
Promise
<User
>
unlinkWallet
• unlinkWallet: (address
: string
) => Promise
<User
>
Type declaration
▸ (address
): Promise
<User
>
Unlink a wallet account from a user, by passing the public address. Note that you can only unlink a wallet account if the user has at least one other account. If the unlinked wallet was the active one, and more wallets are linked to the user, then we attempt to make the most recently linked wallet active.
Parameters
Name | Type |
---|---|
address | string |
Returns
Promise
<User
>
user
• user: null
| User
The user object, or null if the user is not authenticated.
walletConnectors
• walletConnectors: null
| ConnectorManager
Deprecated
Deprecated: This feature will be removed and should be replaced by the
useWallet
hook.
Get the ConnectorManager object This shouldn't need to be used directly unless creating a plugin, like a WAGMI plugin