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 withdrawal flows using the unified deposit API. 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

Create src/hooks/useAmplify.ts:
Call the hook near the root of your app (inside App or a layout component). For advanced configuration options, see SDK Initialization.

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 the App with Unified Deposit API

Add src/app/App.tsx:
  • Replace hard-coded amounts with user inputs and vault selections sourced from the API.
  • Add React Query mutations around each flow to display optimistic states and capture errors.
  • Surface APIError payloads in telemetry and show a fallback UI for unsupported assets.
  • Extract deposit and withdraw 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.