This is a minimal template for integrating Privy Auth into a new create-react-app project. Check out the deployed app here!
- Clone this repository and open it in your terminal.
git clone https://github.com/privy-io/create-react-app.git
- Install the necessary dependencies (including Privy Auth) with
npm.
npm i - Initialize your environment variables by copying the
.env.examplefile to an.envfile. 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
VITE_PRIVY_APP_ID=<your-privy-app-id>In your project directory, run npm run dev. You can now visit http://localhost:5173 (or the port Vite chooses if 5173 is busy) to see your app and login with Privy!
src/index.jsxfor how to use thePrivyProviderand initialize it with your Privy App IDsrc/App.jsxfor how to use theusePrivy()hook, fields likeauthenticatedanduser, and methods likeloginandlogout
Check out our docs for more guidance around using Privy in your app!