Skip to main content
This walkthrough bootstraps a Vite + React project that authenticates users with Privy, initializes the Amplify SDK, and wires up deposit plus bulk-withdraw flows. Follow the steps end-to-end or cherry-pick the sections that fit your stack.
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

Install the runtime dependencies:
Install type support if you use tests:

2. Configure Environment Variables

Create .env.local (ignored by Vite by default):
Never commit this file. Provide an .env.example without secrets for teammates.

3. Set Up Global Providers

Create src/app/providers.tsx:
Wire the providers in src/main.tsx:

4. Initialize the Amplify SDK Once

Create src/hooks/useAmplify.ts:
Call the hook near the root of your app (inside App or a layout component).

5. Build Wallet & Session State

Create src/hooks/useWalletSession.ts:
The usePrivy and useWallets hooks come directly from the official Privy React SDK. Wait for ready before inspecting wallets.

6. Create a Starter App

Add src/app/App.tsx:
  • 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 APIError payloads 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.

8. Starter Repository Layout

Clone this structure in your org repo and extend it with routing, feature flags, and analytics as needed. Tie everything back to the Developer Guide for deployment practices and keep Functions handy as you add more flows.***