@solana/kit ships createClient, a small host you extend with plugins. Each
plugin adds a capability — an RPC connection, a signer, transaction planning —
and the composed client backs scripts, server routes, and UIs alike.
Building a React app? The React guide wraps this
same client with
@solana/react so components read wallet state and RPC data
through hooks. Start there and drop back here when you need finer control.Install
Terminal
@solana/kit-plugin-* packages are
0.13+. @solana-program/system provides the transfer instruction in
Send a transaction.
Create a client
Compose plugins with.use(...). Set a signer first, then the RPC connection.
solanaDevnetRpc() adds client.rpc, subscriptions, the transaction
planner/executor, and the client.sendTransaction helper — so an app rarely
needs to wire those pieces itself.
signer plugin sets both the fee payer and the app identity. The RPC bundle
requires a payer to be in place first, which is why the order matters.
Signer variants
@solana/kit-plugin-signer exposes three roles so you only grant what a client
needs:
signer(x)— sets bothclient.payerandclient.identity.payer(x)— fee payer only.identity(x)— app authority only.
*FromFile(path) (Node), generated*(), generated*WithSol(amount),
and airdrop*() variants for tests and scripts. The *WithSol and airdrop*
variants call client.airdrop, so use them on a local validator.
Send a transaction
Build instructions with a generated program client, then hand them toclient.sendTransaction. The planner resolves the blockhash, estimates compute,
signs with the client’s payer, and submits.
The payer from Create a client is a new keypair with no SOL,
so it can’t pay the fee or the transfer yet. client.airdrop calls the
network’s RPC faucet, which public devnet no longer serves, so fund the payer on
a local validator or load a devnet keypair you funded yourself:
Start a local validator with
surfpool start (install the
Surfpool CLI) or
solana-test-validator. This version swaps solanaDevnetRpc() for
solanaLocalRpc() and airdrops 1 SOL to the payer before the transfer:sendTransaction resolves to a result object; the transaction signature is at
result.context.signature. It asserts the plan fits a single transaction and
throws otherwise — use sendTransactions when a batch may span multiple
transactions.
Pick an RPC bundle
@solana/kit-plugin-rpc ships cluster presets:
solanaDevnetRpc()— devnet defaults. It addsclient.airdrop, but the public devnet RPC no longer serves airdrops; get devnet SOL from the Solana Faucet.solanaMainnetRpc({ rpcUrl: "https://..." })— mainnet;rpcUrlis required, and airdrop is a compile-time error.solanaLocalRpc()—http://127.0.0.1:8899for a local validator, with a workingclient.airdrop.solanaRpc({ rpcUrl })— any endpoint.
Compose granularly
The presets bundle the RPC connection, planner, executor, and send helpers, so most apps never need the pieces individually. Drop to the granular plugins only to customize one — for example a custom planner or a different subscription channel. This path also needs@solana/kit-plugin-instruction-plan, which the
presets otherwise include for you:
Add program clients
Generated@solana-program/* packages expose client plugins so program calls
hang off the client. Install the program you need and .use() its plugin:
Signing without a browser wallet
Running headless in an API route, worker, or script? Sign with a backend key-management service instead of a raw keypair. See Keychain and Signing in Production.Common patterns for Solana devs
- Shared setup: Build the client once in a core module and import it into scripts, server routes, and your UI.
- Server-side reads: A client with just
signer+solanaRpc(no wallet plugin) reads accounts and simulates transactions from the server. - Local testing: Swap the RPC bundle for
.use(litesvm())from@solana/kit-plugin-litesvmto run against an in-memory validator (Node only). - Testability: The composed client is easy to mock — stub RPC responses or signers without a browser wallet present.