- React
- React Native
- Swift
- Android
- Flutter
Login with Passkey
loginWithPasskey from the useLoginWithPasskey hook to trigger the passkey login flow.loginWithPasskey: ({ passkey?: string }) => void
Usage
import { useLoginWithPasskey } from '@privy-io/react-auth';
export default function LoginWithPasskey() {
const { loginWithPasskey } = useLoginWithPasskey();
return (
<div>
<button onClick={loginWithPasskey}>Log in with passkey</button>
</div>
);
}
Sign up with Passkey
UsesignupWithPasskey from the useSignupWithPasskey hook to trigger the passkey signup flow.signupWithPasskey: () => void
Usage
import { useSignupWithPasskey } from '@privy-io/react-auth';
export default function SignupWithPasskey() {
const { signupWithPasskey } = useSignupWithPasskey();
return (
<div>
<button onClick={signupWithPasskey}>Sign up with passkey</button>
</div>
);
}
Tracking Flow State
Track the state of the passkey flow via thestate variable returned by both the
useLoginWithPasskey and useSignupWithPasskey hooks.state:
| {status: 'initial'}
| {status: 'error'; error: Error | null}
| {status: 'generating-challenge'}
| {status: 'awaiting-passkey'}
| {status: 'submitting-response'}
| {status: 'done'};
Callbacks
You can optionally pass callbacks into theuseLoginWithPasskey and useSignupWithPasskey hooks to run custom logic after a successful login or signup, or to handle errors that occur during the flow.onComplete
onComplete: ({user, isNewUser, wasAlreadyAuthenticated, loginMethod, linkedAccount}) => void
Parameters
onError
onError: (error: Error) => void
Parameters
Resources
Login with Passkey
UseloginWithPasskey from the useLoginWithPasskey hook to authenticate users using a passkey. Before using this method, ensure you have setup passkeys as described in this guide.loginWithPasskey: ({ relyingParty: string }) => Promise<PrivyUser>
Parameters
https://example.com).Response
Hide child attributes
Hide child attributes
Show Account Types
Show Account Types
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Usage
import {useLoginWithPasskey} from '@privy-io/expo/passkey';
export function LoginButton() {
const {loginWithPasskey} = useLoginWithPasskey();
return (
<Button onPress={() => loginWithPasskey({relyingParty: '<your-applications-relying-party>'})}>
Login
</Button>
);
}
Sign up with Passkey
UsesignupWithPasskey from the useSignupWithPasskey hook to sign up users using a passkey.signupWithPasskey: ({ relyingParty: string }) => Promise<PrivyUser>
Parameters
https://example.com).Response
Hide child attributes
Hide child attributes
Show Account Types
Show Account Types
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Usage
import {useSignupWithPasskey} from '@privy-io/expo/passkey';
export function SignupButton() {
const {signupWithPasskey} = useSignupWithPasskey();
return (
<Button onPress={() => signupWithPasskey({relyingParty: '<your-applications-relying-party>'})}>
Signup
</Button>
);
}
Tracking Flow State
Track the state of the passkey flow via thestate variable returned by both the
useLoginWithPasskey and useSignupWithPasskey hooks.state:
| {status: 'initial'}
| {status: 'error'; error: Error | null}
| {status: 'generating-challenege'}
| {status: 'awaiting-passkey'}
| {status: 'submitting-response'}
| {status: 'done'};
Callbacks
You can optionally pass callbacks into theuseLoginWithPasskey and useSignupWithPasskey hooks to run custom logic after a successful login or signup, or to handle errors that occur during the flow.onSuccess
onSuccess: (user: PrivyUser, isNewUser: boolean) => Promise<void>
Parameters
Hide child attributes
Hide child attributes
Show Account Types
Show Account Types
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Usage
import {useLoginWithPasskey} from '@privy-io/expo/passkey';
export function LoginScreen() {
const {loginWithPasskey} = useLoginWithPasskey({
onSuccess(user, isNewUser) {
// show a toast, send analytics event, etc...
},
});
// ...
}
onError
onError: (error: Error) => Promise<void>
Parameters
Usage
import {useLoginWithPasskey} from '@privy-io/expo/passkey';
export function LoginScreen() {
const {loginWithPasskey} = useLoginWithPasskey({
onError(error) {
// show a toast, update form errors, etc...
},
});
// ...
}
Resources
Login with Passkey
Uselogin from the privy.passkey interface to authenticate an existing user who has already registered a passkey. This method allows returning users to log in using their previously created passkey credentials. Before using this method, ensure you have setup passkeys as described in the passkey setup guide.func login(relyingParty: String) async throws -> PrivyUser
Parameters
https://example.com).Returns
Usage
do {
let user = try await privy.passkey.login(relyingParty: relyingParty)
// Successfully authenticated an existing user with a passkey
} catch {
print("Login failed: \(error.localizedDescription)")
}
Sign up with Passkey
Usesignup from the privy.passkey interface to create a new user account and register a passkey for them. This method creates a new user in your Privy app, whereas login authenticates an existing user who has already registered a passkey.func signup(relyingParty: String, displayName: String?) async throws -> PrivyUser
Parameters
https://example.com).Returns
Usage
do {
let displayName = "Optional Display Name"
let user = try await privy.passkey.signup(
relyingParty: relyingParty,
displayName: displayName
)
// Successfully created a new user with authenticated by a passkey
} catch {
print("Signup failed: \(error.localizedDescription)")
}
Login with Passkey
Uselogin from the privy.passkey interface to authenticate an existing user who has already registered a passkey. This method allows returning users to log in using their previously created passkey credentials. Before using this method, ensure you have setup passkeys as described in the passkey setup guide.suspend fun login(relyingParty: String): Result<PrivyUser>
Parameters
https://example.com).Response
Returns aResult<PrivyUser> containing the user object after successful login.Show PrivyUser
Show PrivyUser
Show Properties
Show Properties
Show CustomAuth
Show CustomAuth
Show EmbeddedEthereumWalletAccount
Show EmbeddedEthereumWalletAccount
Show EmbeddedSolanaWalletAccount
Show EmbeddedSolanaWalletAccount
Show ExternalWalletAccount
Show ExternalWalletAccount
Show PhoneAccount
Show PhoneAccount
Show EmailAccount
Show EmailAccount
Show GoogleOAuthAccount
Show GoogleOAuthAccount
Show TwitterOAuthAccount
Show TwitterOAuthAccount
Show DiscordOAuthAccount
Show DiscordOAuthAccount
Show PasskeyAccount
Show PasskeyAccount
Usage
val result = privy.passkey.login(relyingParty = "https://<your-applications-relying-party>")
result.fold(
onSuccess = { user ->
// Handle successful login
},
onFailure = { error ->
// Handle login error
}
)
Sign up with Passkey
Usesignup from the privy.passkey interface to create a new user account and register a passkey for them. This method creates a new user in your Privy app, whereas login authenticates an existing user who has already registered a passkey.suspend fun signup(relyingParty: String, displayName: String? = null): Result<PrivyUser>
Parameters
https://example.com).Response
Returns aResult<PrivyUser> containing the user object after successful signup.Show PrivyUser
Show PrivyUser
Show Properties
Show Properties
Show CustomAuth
Show CustomAuth
Show EmbeddedEthereumWalletAccount
Show EmbeddedEthereumWalletAccount
Show EmbeddedSolanaWalletAccount
Show EmbeddedSolanaWalletAccount
Show ExternalWalletAccount
Show ExternalWalletAccount
Show PhoneAccount
Show PhoneAccount
Show EmailAccount
Show EmailAccount
Show GoogleOAuthAccount
Show GoogleOAuthAccount
Show TwitterOAuthAccount
Show TwitterOAuthAccount
Show DiscordOAuthAccount
Show DiscordOAuthAccount
Show PasskeyAccount
Show PasskeyAccount
Usage
val result = privy.passkey.signup(relyingParty = "https://<your-applications-relying-party>")
result.fold(
onSuccess = { user ->
// Handle successful signup
},
onFailure = { error ->
// Handle signup error
}
)
Login with Passkey
Uselogin from the privy.passkey interface to authenticate an existing user who has already registered a passkey. This method allows returning users to log in using their previously created passkey credentials. Before using this method, ensure you have setup passkeys as described in the passkey setup guide.Future<Result<PrivyUser>> login({
required String relyingParty,
})
Parameters
https://example.com).Response
Returns aResult<PrivyUser> containing the user object after successful login.Usage
final result = await privy.passkey.login(
relyingParty: "https://<your-applications-relying-party>",
);
result.fold(
onSuccess: (user) {
// Handle successful login
},
onFailure: (error) {
// Handle login error
},
);
Sign up with Passkey
Usesignup from the privy.passkey interface to create a new user account and register a passkey for them. This method creates a new user in your Privy app, whereas login authenticates an existing user who has already registered a passkey.Future<Result<PrivyUser>> signup({
required String relyingParty,
String? displayName,
})
Parameters
https://example.com).Response
Returns aResult<PrivyUser> containing the user object after successful signup.Usage
final result = await privy.passkey.signup(
relyingParty: "https://<your-applications-relying-party>",
displayName: "My Passkey", // optional
);
result.fold(
onSuccess: (user) {
// Handle successful signup
},
onFailure: (error) {
// Handle signup error
},
);

