The snippets use the latest Privy React SDK (
@privy-io/react-auth) APIs.
Wait for ready from usePrivy and useWallets before inspecting user or
wallet state to avoid race conditions.1. Scaffold the Project
2. Configure Environment Variables
Create.env.local (ignored by Vite by default):
.env.example without secrets for teammates.
3. Set Up Global Providers
Createsrc/app/providers.tsx:
src/main.tsx:
4. Initialize the Amplify SDK Once
Createsrc/hooks/useAmplify.ts:
App or a layout component).
5. Build Wallet & Session State
Createsrc/hooks/useWalletSession.ts:
usePrivy and useWallets hooks come directly from the official Privy React SDK. Wait for ready before inspecting wallets.
6. Create a Starter App
Addsrc/app/App.tsx:
7. Recommended Enhancements
- Replace hard-coded addresses with vault selections sourced from the API.
- Add React Query mutations around each helper to display optimistic states and capture errors.
- Surface
APIErrorpayloads in telemetry and show a fallback UI for unsupported assets. - Extract transaction logic into reusable hooks (
useDeposit,useWithdraw). - Add analytics around wallet connection and transaction success rates.