This guide walks you through setting up Privy authentication for GitStream.
- A Privy account (sign up at https://dashboard.privy.io)
- Access to your GitStream monorepo
- Go to Privy Dashboard
- Create a new app or select your existing app
- Navigate to Settings → Basics
- Copy your:
- App ID (public, starts with
clp...) - App Secret (private, keep secure!)
- App ID (public, starts with
-
Navigate to the API directory:
cd apps/api -
Open your
.envfile and add the Privy configuration:# Privy Authentication PRIVY_APP_ID=your_privy_app_id_here PRIVY_APP_SECRET=your_privy_app_secret_here
-
Important: Keep your
PRIVY_APP_SECRETsecure and never commit it to version control
-
Navigate to the web directory:
cd apps/web -
Open your
.env.localfile and add (or verify):# Privy Authentication NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id_here
-
Note: The frontend only needs the App ID (not the secret)
In your Privy Dashboard, configure the following:
Add your application domains:
- Development:
http://localhost:3000 - Production:
https://yourdomain.com
Enable the methods you want users to use:
- ✅ Wallet (recommended)
- ✅ GitHub
Configure embedded wallet settings:
- Enable "Create on login" for users without wallets
- Set default chain to Base Sepolia (Chain ID: 84532)
Add the chains your app will use:
- Base Sepolia (testnet)
- Base (mainnet, when ready)
After configuring the environment variables:
- Stop all running services
- Restart the API:
cd apps/api pnpm dev - Restart the frontend:
cd apps/web pnpm dev
To verify Privy is working correctly:
- Open your app at
http://localhost:3000 - Click the Connect button
- You should see the Privy login modal
- After authenticating, try creating a new project
- Check the API logs - you should see successful authentication
Cause: Backend missing Privy credentials or credentials are incorrect
Solution:
- Verify
PRIVY_APP_IDandPRIVY_APP_SECRETare set inapps/api/.env - Restart the API server
- Check API logs for detailed error messages
Cause: Token verification failed
Solutions:
- Verify the App ID matches between frontend and backend
- Check that the App Secret is correct
- Ensure the token hasn't expired (auto-refresh should handle this)
- Verify your app domain is whitelisted in Privy Dashboard
Cause: User authenticated without a wallet
Solutions:
- Enable embedded wallets in Privy Dashboard
- Configure "Create on login: users-without-wallets"
- Ask user to connect a wallet in Privy modal
- User clicks "Connect" → Privy modal opens
- User authenticates via wallet/email/social
- Privy creates a session and returns an access token
- Frontend stores token and includes it in API requests:
const token = await getAccessToken(); fetch('/api/projects', { headers: { 'Authorization': `Bearer ${token}` } });
- API receives request with
Authorization: Bearer {token}header - Auth middleware extracts the token
- Privy SDK verifies the token signature and expiration
- Gets user data from Privy (including wallet address)
- Stores wallet address in request context
- Route handler uses
c.get('walletAddress')to access authenticated user
- Never commit secrets: Add
.envto.gitignore - Use different keys: Use separate Privy apps for dev/staging/production
- Rotate secrets: Periodically rotate your App Secret
- Monitor usage: Check Privy Dashboard for unusual activity
- Validate on backend: Always verify tokens on the backend, never trust client
If you continue to experience issues:
- Check the detailed error logs in your API console
- Review the Privy Dashboard logs
- Consult the Privy Discord community