Skip to main content
This recipe uses the Dynamic JavaScript SDK (@dynamic-labs-sdk/client + @dynamic-labs-sdk/solana). The React tab also uses @dynamic-labs-sdk/react-hooks. See the Quickstart for the base setup.

Prerequisites

  • The Dynamic JS SDK initialized, with the Solana extension registered via addSolanaExtension() — see Adding Solana Extensions
  • Installed dependencies:
    • @coral-xyz/anchor
    • @solana/web3.js
    • @dynamic-labs-sdk/client
    • @dynamic-labs-sdk/solana
    • For the React tab: @dynamic-labs-sdk/react-hooks and @tanstack/react-query (DynamicProvider mounted at the root — see the React Quickstart)
  • Your Anchor program’s IDL and TypeScript types

Step 1: Build the Anchor provider

Adapt the SDK’s transaction-signing helpers to the Wallet interface Anchor expects.
Create a file (e.g., anchor-provider.ts) and add the following code:

Step 2: Wrap your app with the provider

If you’re using the JavaScript tab from Step 1, skip this step — call createAnchorProvider() directly wherever you need the program. For the React context, mount AnchorProviderComponent inside DynamicProvider so it can read the connected wallet from the JS SDK’s hooks. QueryClientProvider must wrap DynamicProvider — every hook in @dynamic-labs-sdk/react-hooks is built on TanStack Query.

Step 3: Call a program method

Here’s an example of calling a program method and sending a transaction using the connected Dynamic wallet.

Summary

By following this guide, you can connect your Solana Anchor programs to your 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 August 18, 2026