Skip to main content
Learn how to set up Privy with Base Account to enable seamless user authentication and wallet management.

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
You can jump ahead and use the Base Account Privy Template to get started.
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:
Or you can use a specific version by adding the version to the overrides:
If you’re not starting a new projectsMake sure to delete your node_modules and package-lock.json and run a new install to ensure the overrides are applied.

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:
Get your Privy App ID from the Privy Dashboard.

2. Configure Privy Provider

Create your Privy configuration with Base Account as the default login method and update the layout to include the PrivyProvider.

Usage

1. Update the App Page

Update the app/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:
You should see a page that looks like this:
Base × Privy Demo

3. Get the Base Account SDK instance (Optional)

You can access the Base Account SDK from Privy using the useBaseAccount hook.
Get the SDK instance