Skip to main content

Quickstart

The Privy React Auth SDK allows you to authenticate your users with Privy in your React app.

With just ten minutes of setup, you get:

  • immediate support for email, SMS, wallet, and social (Google, Twitter, Discord, etc.) logins
  • progressive authentication flows that reduce friction during onboarding
  • out-of-the-box UIs, styled with your brand, that guide your users & keep them informed
  • identity management across your user base

and so much more!

tip

Building a new app? Check out our starter templates for integrating Privy into:

1. Installation

Install the Privy React Auth SDK using npm:

npm install @privy-io/react-auth

2. Configuring Privy Auth

To use Privy Auth, the first step is to retrieve your Privy app ID from the developer console at console.privy.io. If this is your first time using Privy Auth, please reach out so we can set you up with a Privy account and app ID.

From the developer console, you may also configure various settings for your app, including its name, logo, accent color, and more. These will be shown to your users at various points in their onboarding experience.

3. Setting up your app

Once you have your app ID, in your React project, wrap your components with a PrivyProvider. The PrivyProvider should wrap any component that will use the Privy Auth SDK.

For example, in a NextJS or Create React App project, you may wrap your components as so:

_app.jsx
import type {AppProps} from 'next/app';
import Head from 'next/head';
import {PrivyProvider} from '@privy-io/react-auth';

// This method will be passed to the PrivyProvider as a callback
// that runs after successful login.
const handleLogin = (user) => {
console.log(`User ${user.id} logged in!`)
}

function MyApp({Component, pageProps}: AppProps) {
return (
<>
<Head>
{/* Edit your HTML header */}
</Head>
<PrivyProvider
appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID}
onSuccess={handleLogin}
>
<Component {...pageProps} />
</PrivyProvider>
</>
);

The PrivyProvider takes the following properties:

4. Just usePrivy! 🎉

You can now use the Privy SDK throughout your app via the usePrivy hook! Check out our starter repo to see what a simple end-to-end integration looks like.

Read on to learn how you can use Privy to:

and to do so much more!

info

Can't find something in our docs, or have a question that isn't answered here? Reach out to [email protected]! We'd love to help you find what you're looking for.