Connecting to a Solana RPC
To start Kite, you need to connect to a Solana RPC - RPCs are how your code communicates with the Solana blockchain.
To use the local cluster (ie, solana-test-validator running on your machine):
import { connect } from "solana-kite";
const connection = connect();You can also specify a cluster name. The connection object defaults to localnet but any of the following cluster names are supported:
devnet- Development network for testing with fake SOL. This is where Solana apps developers typically deploy first.mainnet-beta(ormainnet) - Main Solana network where transactions involving real value occur.testnet- Used to test future versions of the Solana blockchain.quicknode-mainnet,quicknode-devnet- the Quicknode names require the environment variablesQUICKNODE_SOLANA_MAINNET_ENDPOINT(for mainnet) orQUICKNODE_SOLANA_DEVNET_ENDPOINT(for devnet) to be set in your environment. You can get an API key from Quicknode .
const connection = connect("quicknode-devnet");-
helius-mainnet,helius-testnet, orhelius-devnet- the Helius names require the environment variableHELIUS_API_KEYto be set in your environment. You can get an API key from Helius . -
triton-mainnet,triton-devnet,triton-testnet- the Triton names require environment variables to be set:TRITON_SOLANA_MAINNET_ENDPOINTfor mainnetTRITON_SOLANA_DEVNET_ENDPOINTfor devnetTRITON_SOLANA_TESTNET_ENDPOINTfor testnet
You can get an API endpoint from Triton .
const connection = connect("triton-devnet");You can also specify an arbitrary RPC URL and RPC subscription URL:
const connection = connect("https://mainnet.example.com/", "wss://mainnet.example.com/");After you’ve made a connection Kite is ready to use.
If you’re used to raw @solana/kit you don’t need to set up any factories, they’re already configured.
Using Kite as a Plugin (Advanced)
⭐ New in Kite 3.0.0
For advanced users who want to integrate Kite into an existing @solana/kit RPC setup, you can use Kite as a plugin:
import { createSolanaRpc } from "@solana/kit";
import { createKitePlugin } from "solana-kite";
// Create your RPC connection
const rpc = createSolanaRpc("https://api.devnet.solana.com");
// Use Kite as a plugin
const connection = rpc.use(createKitePlugin({
clusterNameOrURL: 'devnet'
}));
// Now you can use Kite functions
const wallet = await connection.createWallet();Plugin vs Traditional Connection
Traditional (Recommended for most users):
const connection = connect('devnet');Plugin Pattern (For advanced RPC customization):
const rpc = createSolanaRpc('devnet');
const connection = rpc.use(createKitePlugin({ clusterNameOrURL: 'devnet' }));Use the plugin pattern when:
- You need custom RPC transport configuration
- You’re integrating Kite into existing
@solana/kitcode - You need fine-grained control over RPC connection settings
For most users, the traditional connect() approach is simpler and recommended.