> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana Connection

A Connection is the object you use to talk to a Solana node over JSON-RPC.
You point it at an RPC endpoint (devnet/testnet/mainnet or a custom URL) and then use it to read chain state and send/simulate transactions.

We provide a helper method to allow you to create a Solana Connection given some network data.

## Usage

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"system"}
    import { getActiveNetworkData } from '@dynamic-labs-sdk/client';
    import { getSolanaConnection } from '@dynamic-labs-sdk/solana';

    const someAction = async (walletAccount) => {
      // you can use your custom NetworkData object or get the active network data from a wallet account
      // with the getActiveNetworkData function

      const { networkData } = await getActiveNetworkData({ walletAccount });

      const connection = getSolanaConnection({ networkData });

       // Connection is now ready to use
    };
    ```
  </Tab>

  <Tab title="React">
    Derive the connection from `useGetActiveNetworkData`, which automatically re-fetches when the wallet account changes or the user switches networks:

    ```tsx theme={"system"}
    import { getSolanaConnection } from '@dynamic-labs-sdk/solana';
    import { useGetActiveNetworkData } from '@dynamic-labs-sdk/react-hooks';
    import { useMemo } from 'react';

    function useSolanaConnection(walletAccount) {
      const { data: activeNetwork } = useGetActiveNetworkData({ walletAccount });

      return useMemo(
        () => (activeNetwork?.networkData ? getSolanaConnection({ networkData: activeNetwork.networkData }) : null),
        [activeNetwork],
      );
    }
    ```
  </Tab>
</Tabs>

## Related functions

* [Get active network](/javascript/reference/wallets/get-active-network)
* [Signing and Sending Transactions](/javascript/reference/solana/signing-sending-transactions)
* [Adding Solana extensions](/javascript/reference/solana/adding-solana-extensions)
