Skip to main content
Make sure you enable SVM chain in the Dynamic dashboard.

Installation

npm install @dynamic-labs-sdk/solana

Default Solana extension

If you wish to support the standard Solana wallets and Dynamic embedded wallets, you can add the default Solana extension to your client using the addSolanaExtension method.
import { createDynamicClient } from '@dynamic-labs-sdk/client';
import { addSolanaExtension } from '@dynamic-labs-sdk/solana';

const dynamicClient = createDynamicClient({
  ...
});

addSolanaExtension();

Standalone Solana extensions

If you want to be more granular, you can add the standalone Solana extensions individually to your client.

Solana Wallets Standard extension

import { addSolanaWalletStandardExtension } from '@dynamic-labs-sdk/solana/walletStandard';

const dynamicClient = createDynamicClient({
  ...
});

// this will add support for wallets that implement the Solana Wallets Standard
addSolanaWalletStandardExtension();

WAAS Solana extension

import { addWaasSolanaExtension } from '@dynamic-labs-sdk/solana/waas';

const dynamicClient = createDynamicClient({
  ...
});

// this will add support for Dynamic embedded Solana wallets only
addWaasSolanaExtension();

Phantom redirect extension

Adds support for connecting to Phantom on mobile via deep link redirects. This is not included in addSolanaExtension and must be added separately. It is intended for mobile web apps where users open your app inside a mobile browser and need to interact with their Phantom wallet.
import { addPhantomRedirectSolanaExtension } from '@dynamic-labs-sdk/solana/phantom-redirect';

const dynamicClient = createDynamicClient({
  ...
});

// must be called on every page load, passing the current URL so the extension
// can detect and complete any in-progress Phantom redirect
addPhantomRedirectSolanaExtension({ url: new URL(window.location.href) });

See Phantom Redirect Extension for full setup details and how the redirect flow works.

Combining extensions

You can combine as many extensions as you want to support all the wallets you want to support.
import { addSolanaWalletStandardExtension } from '@dynamic-labs-sdk/solana/walletStandard';
import { addWaasSolanaExtension } from '@dynamic-labs-sdk/solana/waas';

const dynamicClient = createDynamicClient({
  ...
});

addSolanaWalletStandardExtension();
addWaasSolanaExtension();