Skip to main content

ConnectionProvider

What is ConnectionProvider?

ConnectionProvider is a React context provider. It allows your application to connect to a specific Solana network endpoint (such as the mainnet, devnet, or testnet). Once connected, it shares this connection with all its child components, enabling them to interact with the blockchain seamlessly.

Props:

endpoint (string):

By specifying this endpoint, you tell your app which blockchain instance to use.

children (ReactNode):

  • This refers to the components of your application that require access to the Solana connection. These components are placed inside the ConnectionProvider, and they inherit the connection context.

Example in layout.tsx:

import {  ReactNode } from "react";
import { ConnectionProvider } from '@solana/wallet-adapter-react';

export default function RootLayout({ children }: { children: ReactNode }) {
return (
<ConnectionProvider endpoint="https://api.mainnet-beta.solana.com">
{children}
</ConnectionProvider>
);
}