Using the vanilla JavaScript SDK
The @privy-io/js-sdk-core
library is a vanilla JavaScript library, intended for use in a browser-like environment, it allows you to add secure authentication, non-custodial embedded wallets, and powerful user management into your application.
@privy-io/js-sdk-core
library is a low-level JavaScript 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, make sure you have set up your Privy app and obtained your app ID from the Privy Dashboard.
Installation
Getting a Privy
instance
Import the Privy
class and create an instance of it, passing the Privy app ID and app client ID and storage adapter. You may also configure any EVM chains you would like to support.
You should ensure that there is only ever one instance of the Privy client instantiated for your app.
Connecting to the secure context
Configure the Privy SDK with the Privy iframe to be able to provision non-custodial embedded wallets for your users.
First, create and mount an iframe in your app, use the Privy client to get the src URL.
Then, pass through a reference to the iframe to the Privy client and attach listeners for message events.
If you are using a UI rendering library or framework we recommend rendering the iframe and registering listener using that library instead of using the DOM directly.
Authentication
The Privy core SDK supports a variety of authentication options including email, SMS, OAuth and JWT-based auth.
Creating a an embedded wallet
Your app can manually create wallets for users when desired.
Using the embedded wallet
In order to send a transaction, your wallet must have some funds to pay for gas. You can use a testnet faucet to test transacting on a testnet (e.g. Base Sepolia) or send funds to the wallet on the network of your choice.
With the users’ embedded wallet, your application can now prompt the user to sign and send transactions.
Learn more about sending transactions with the embedded wallet. Privy enables you to take many actions on the embedded wallet, including sign a message, sign typed data, and sign a transaction.