Skip to content

privy-io/create-react-app

Repository files navigation

Privy Auth create-react-app Starter

This is a minimal template for integrating Privy Auth into a new create-react-app project. Check out the deployed app here!

Setup:

  1. Clone this repository and open it in your terminal.
git clone https://github.com/privy-io/create-react-app.git
  1. Install the necessary dependencies (including Privy Auth) with npm.
npm i 
  1. Initialize your environment variables by copying the .env.example file to an .env file. Then, paste your Privy App ID from the console in .env.
# In your terminal, create .env from .env.example
cp .env.example .env

# Add your Privy App ID to .env
REACT_APP_PRIVY_APP_ID=<your-privy-app-id>

Building locally:

In your project directory, run npm run start. You can now visit http://localhost:3000 to see your app and login with Privy!

Check out:

  • src/index.js for how to use the PrivyProvider and initialize it with your Privy App ID
  • src/App.js for how to use the usePrivy() hook, fields like authenticated and user, and methods like login and logout
  • config-overrides.js for how to handle common issues with Webpack 5

Check out our docs for more guidance around using Privy in your app!