@privy-io/js-sdk-core library is a vanilla JavaScript library for browser-like environments. It provides secure authentication, non-custodial embedded wallets, and user management without requiring React or any other UI framework.
@privy-io/js-sdk-core is a low-level library. Please do not attempt to use this library without
first reaching out to the Privy team to discuss your project and which Privy SDK options may be
better suited to it.Prerequisites
Before you begin:- Set up your Privy app and obtain your app ID from the Privy Dashboard
- Obtain your client ID from the Dashboard under Settings → Clients
Installation
1. Create the Privy client
Import thePrivy class and create a single instance for your application. The client accepts the following configuration:
Custom storage adapters
Custom storage adapters
The
Storage interface requires four methods. Implement this interface if LocalStorage is not suitable for your environment (e.g., encrypted storage, server-side rendering, or non-browser runtimes):2. Initialize the client
After creating the client, callinitialize() to establish a connection with the Privy backend and restore any existing session. This must complete before performing any other operations.
After
initialize() resolves, call client.user.get() to check for an existing authenticated
session. If the user previously logged in and the session is still valid, this returns the user
object without requiring re-authentication.Restoring a returning user’s session
3. Connect to the secure context
The Privy secure context is an iframe that handles embedded wallet key material. Your app must mount this iframe and wire up bidirectional message passing.Mount the iframe
Wire up message passing
4. Authenticate a user
The Privy core SDK supports email, SMS, OAuth, and JWT-based authentication.5. Get access tokens for your backend
After authentication, usegetAccessToken() to retrieve the user’s access token. Include this token in requests to your backend to verify the user’s identity.
getAccessToken() automatically handles token refresh when the access token is near expiration.
The returned token is always valid at the time of return.6. Create an embedded wallet
Your app can manually create wallets for users when desired.Privy can provision wallets for your users on both Ethereum and Solana.
7. Connect to an existing wallet
When a user returns to your app on a subsequent visit, the wallet already exists but a provider must be obtained.8. Use the embedded wallet
Your wallet must have funds to pay for gas. Use a testnet
faucet to test on Base Sepolia, or send funds to the wallet
on your preferred network.

