Prerequisites
- A React or Next.js app set up with Dynamic’s React SDK
- Installed dependencies:
@coral-xyz/anchor
@solana/web3.js
@dynamic-labs/sdk-react-core
@dynamic-labs/solana
- Your Anchor program’s IDL and TypeScript types
Step 1: Create the Anchor Provider Context
Create a file (e.g.,AnchorProviderComponent.tsx
) and add the following code. This context will provide your Anchor program, connection, provider, and public key throughout your app.
Step 2: Wrap Your App with the Provider
Wrap your app with theAnchorProviderComponent
so all child components can access the Anchor context.