Skip to main content

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 the AnchorProviderComponent so all child components can access the Anchor context.

Step 3: Use the Hook in Your Components

You can now access the Anchor context anywhere in your component tree. Here’s an example of calling a program method and sending a transaction using the Dynamic wallet:

Summary

By following this guide, you can connect your Solana Anchor programs to your React or Next.js app using Dynamic for wallet management. This setup enables seamless smart contract interactions and transaction signing, leveraging the strengths of both Anchor and Dynamic. References:
Last modified on March 30, 2026