JSPM

@privy-io/react-auth

1.20.0-beta.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 48586
  • Score
    100M100P100Q156310F
  • License Apache-2.0

React client for the Privy Auth API

Package Exports

  • @privy-io/react-auth

Readme

@privy-io/react-auth

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

Check out our demo!

⚠️ NOTE: Privy is in beta. APIs and feature sets will change. We use Semantic Versioning to track breaking changes.

Installing

npm i @privy-io/react-auth

Basic Usage

Setup your integration by wrapping any React components that will use the Privy SDK with the PrivyProvider. This gives your wrapped components access to the Privy SDK and authentication context.

// Import the PrivyProvider
import {PrivyProvider} from '@privy-io/react-auth';

// Wrap any components that will use the Privy SDK with the PrivyProvider – for example, in your `app` or `index` file
<PrivyProvider
  appId="APP_ID_FROM_CONSOLE"
  onSuccess={(user) => console.log(`User ${user.id} logged in!`)}
>
  <Component {...pageProps} />
</PrivyProvider>;

Now, from within your React components, you can access the Privy SDK via the usePrivy hook!

// Import the usePrivy hook
import {usePrivy} from '@privy-io/react-auth';

// Call usePrivy() from inside your React components
const {ready, authenticated, user, login, logout} = usePrivy();