Skip to main content

Recommended: JavaScript SDK with React Hooks

For new React apps, we recommend the JavaScript SDK with React Hooks (@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.

Checking if a wallet is a Solana wallet

React
    import { isSolanaWallet } from '@dynamic-labs/solana';

    if (!isSolanaWallet(wallet)) {
      throw new Error('This wallet is not a Solana wallet');
    }

Get Connection

React
    import { useUserWallets } from '@dynamic-labs/sdk-react-core';
    import { isSolanaWallet } from '@dynamic-labs/solana';

    const wallets = useUserWallets();

    const connection = wallets.find(wallet => isSolanaWallet(wallet))?.getConnection();

Get Signer

React
    import { useUserWallets } from '@dynamic-labs/sdk-react-core';
    import { isSolanaWallet } from '@dynamic-labs/solana';
    
    const wallets = useUserWallets();

    const signer = wallets.find(wallet => isSolanaWallet(wallet))?.getSigner();

Custom Connection (React only)

In some cases you would want to override the default settings of the Web3.js Connection. React provides the SolanaWalletConnectorsWithConfig to customize Web3.js Connection configuration with commitment levels, HTTP headers, and custom RPC URLs.
React
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core';
import { SolanaWalletConnectorsWithConfig } from '@dynamic-labs/solana';

<DynamicContextProvider
  settings={{
    walletConnectors: [
      SolanaWalletConnectorsWithConfig({
        commitment: "confirmed",
        httpHeaders: {
          "X-Requested-With": "XMLHttpRequest",
        },
        customRpcUrls: {
          solana: ["http://YOUR_URL"],
          eclipse: ["http://YOUR_URL"],
        },
      }),
    ],
    ... // other settings
  }}
>
  {...}
</DynamicContextProvider>

Examples

You can find examples of how to interact with Solana wallets in the examples section:
Last modified on June 25, 2026