Overview
The@turnkey/sdk-browser
package enables developers to build browser-based applications that interact with the Turnkey API using multiple authentication methods.
It includes:
indexedDbClient
: The recommended client for authentication and session creation using secure, unextractable P-256 keys stored in the browser’s IndexedDB.passkeyClient
: For passkey registration and signing flows.iframeClient
: Used for secure credential injection and import/export operations.walletClient
: For signing with external wallets like MetaMask.
@turnkey/sdk-react
package.
Installation
Initialization
Authentication
loginWithPasskey
Creates a session for a user authenticated with a passkey. The session is stored in localStorage
, and signing operations are done with an unextractable keypair stored in IndexedDB.
loginWithBundle
Used to authenticate a user with a credential bundle (e.g. from Email Auth). Must be used from an iframeClient
.
loginWithSession
Logs in using a session string (JWT) that was created elsewhere (e.g. server action). Only valid on indexedDbClient
.
loginWithWallet
Uses a Web3 wallet to authenticate the user and store a read-write session.
refreshSession
Refreshes the current session and extends its expiration time. The correct publicKey
must be provided for read-write sessions.
IndexedDbClient
TheindexedDbClient
is the recommended way to manage secure keys for session-based authentication.