Skip to main content
This guide covers the recommended project structure and SDK initialization patterns for Amplify SDK integrations. A consistent file layout keeps vault logic, wallet plumbing, and UI concerns easy to reason about:

Separation of Concerns

  • Providers layer – initialize Privy, React Query, and the Amplify SDK once. Re-export hooks for the rest of the app.
  • Hooks layer – wrap SDK helpers (prepareDeposit, prepareWithdrawal) with domain-specific logic and query invalidation.
  • Components layer – pure UI components that receive prepared data plus callbacks for execution.
  • Lib layer – interaction helpers for viem, Privy, or analytics that should not depend on React state.

SDK Initialization

All Amplify SDK functions require initialization before use. Call initAmplifySDK() once at application startup.

Basic Initialization

With Custom RPCs

For the best user experience and reliability, we recommend using your own RPCs:

With Configuration Options

React Integration Hook

Create a hook to initialize the SDK once and expose ready state:

Usage in App

Environment Variables

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

Global Providers

Set up React Query and your wallet provider:
Wire the providers in your entry point:

Server-Side Usage

If you execute transactions from a backend service, mirror the same separation:
  • server/app.ts – Express/Fastify entry point
  • server/clients/amplify.tsinitAmplifySDK and helper wrappers
  • server/services/deposits.ts – orchestrates approvals, permits, or withdrawals

Next Steps