Overview
Privy provides user authentication and wallet management solutions for onchain applications. By integrating Privy with Base Account, you can access all the Privy hooks and methods while having access to the users of Base Account.What you’ll achieve
By the end of this guide, you will:- Set up Privy with Base Account support
- Have Base Account set up as the main authentication option
- Be able to access Base Account SDK from Privy’s React SDK
Base Account Privy Templatehttps://github.com/base/base-account-privy
Installation
1. Create a new Next.js project
2. Override the Base Account SDK version
In order to access the latest version of the Base Account SDK, you need to override the Privy pinned version in your package.json file. To do this, you can use the following command to override it:3. Install the dependencies
Install the dependencies with your package manager of choice:Configuration
1. Set up Environment Variables
Create a.env.local file in your project root:
2. Configure Privy Provider
Create your Privy configuration with Base Account as the default login method and update the layout to include thePrivyProvider.
Usage
1. Update the App Page
Update theapp/page.tsx file to show the authentication flow:
app/page.tsx
2. Run the project locally
You’re done! You can now run the project locally:
3. Get the Base Account SDK instance (Optional)
You can access the Base Account SDK from Privy using theuseBaseAccount hook.
Get the SDK instance