Recommended: JavaScript SDK for React Native
While this SDK is still supported, we recommend using newer JavaScript SDK, which is optimized for React Native, but also comes with a host of other benefits.
Checking if a wallet is a Solana wallet
React Native
import { isSolanaWallet } from '@dynamic-labs/solana';
import { dynamicClient } from '<path to client file>';
const wallet = dynamicClient.wallets.primary;
if (!wallet || !isSolanaWallet(wallet)) {
throw new Error('This wallet is not a Solana wallet');
}
const connection = dynamicClient.solana.getConnection();
```
## Get Connection
<CodeGroup>
```ts dynamicClient.ts
import { createClient } from '@dynamic-labs/legacy-client'
import { SolanaExtension } from '@dynamic-labs/legacy-solana-extension'
export const dynamicClient = createClient({
environmentId: 'YOUR-ENVIRONMENT-ID',
}).extend(SolanaExtension())
```
```ts getConnection.ts
import { dynamicClient } from './dynamicClient';
import { isSolanaWallet } from '@dynamic-labs/solana';
if (!isSolanaWallet(wallet)) {
throw new Error('This wallet is not a Solana wallet');
}
const connection = dynamicClient.solana.getConnection({
commitment: 'singleGossip',
})
```
</CodeGroup>
## Get Signer
<CodeGroup>
```ts dynamicClient.ts
import { createClient } from '@dynamic-labs/legacy-client'
import { SolanaExtension } from '@dynamic-labs/legacy-solana-extension'
export const dynamicClient = createClient({
environmentId: 'YOUR-ENVIRONMENT-ID',
}).extend(SolanaExtension())
```
```ts getSigner.ts
import { dynamicClient } from './dynamicClient';
import { isSolanaWallet } from '@dynamic-labs/solana';
if (!isSolanaWallet(wallet)) {
throw new Error('This wallet is not a Solana wallet');
}
const signer = dynamicClient.solana.getSigner({ wallet })
```
</CodeGroup>
## Custom connection options
To override the default Web3.js Connection settings (e.g. commitment, RPC URLs), pass options to the client's Solana extension: `dynamicClient.solana.getConnection({ commitment: 'confirmed', ... })` (see [Get Connection](#get-connection) above).
## Examples
You can find examples of how to interact with Solana wallets in the examples section:
- [Send a Legacy Solana Transaction](/react-native/wallets/using-wallets/solana/send-legacy-solana-transaction).
- [Send a Versioned Solana Transaction](/react-native/wallets/using-wallets/solana/send-versioned-solana-transaction).