Triggering authentication
You can call the specific login or signup methods you want to support. For example, with passkeys:Checking authentication state
To check if a user is authenticated, callclient.getSession() and verify the expiry:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Learn how to set up authentication that leverages Turnkey’s Auth Proxy using @turnkey/core in your frontend JavaScript application.
// Log in with a passkey
const session = await turnkeyClient.loginWithPasskey();
// Or sign up with a passkey
const session = await turnkeyClient.signUpWithPasskey();
// Log in with email OTP
import { OtpType } from "@turnkey/core";
const otpId = await turnkeyClient.initOtp({ otpType: OtpType.Email, contact: "email@example.com" })
const session = await turnkeyClient.completeOtp({
otpId,
otpCode: 123456, // The code the user received via email or SMS
contact: "email@example.com",
otpType: OtpType.Email,
});
client.getSession() and verify the expiry:
const session = await turnkeyClient.getSession();
if (session && session.expiry \* 1000 > Date.now()) {
console.log("User is authenticated:", session);
} else {
console.log("User is not authenticated");
}
await turnkeyClient.logout();
Was this page helpful?