@solana/kit, Codama & gill (JS/TS)
The modern Solana TypeScript client stack centers on @solana/kit 7.0.0 for RPC, codecs, and transaction messages. Codama generates kit-native clients from Anchor 0.32.1 IDLs. gill is a convenience layer bundling common kit patterns for application code. Together they replace greenfield @solana/web3.js v1 usage on Agave 4.1.1.
Recipe
Quick-reference recipe card - copy-paste ready.
npm install @solana/kit@7.0.0 gill
npm install -D @codama/nodes-from-anchor @codama/renderers-jsimport { createSolanaRpc, address, lamports } from "@solana/kit";
const rpc = createSolanaRpc("https://api.devnet.solana.com");
const balance = await rpc.getBalance(address("11111111111111111111111111111111")).send();
console.log(balance.value);When to reach for this:
- New Next.js or React dApps targeting Agave 4.x RPC.
- Generating typed clients after
anchor buildIDL output. - Tree-shakable functional imports instead of monolithic web3.js classes.
- Shared codecs between frontend and API routes.
Working Example
import {
createSolanaRpc,
createTransactionMessage,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstruction,
signTransactionMessageWithSigners,
getSignatureFromTransaction,
address,
} from "@solana/kit";
import { getTransferSolInstruction } from "@solana-program/system";
import { createKeyPairSignerFromBytes } from "@solana/signers";
import fs from "node:fs";
const rpc = createSolanaRpc("https://api.devnet.solana.com");
const secret = Uint8Array.from(JSON.parse(fs.readFileSync(process.env.KEYPAIR!, "utf8")));
const payer = await createKeyPairSignerFromBytes(secret);
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
let message = createTransactionMessage({ version: 0 });
message = setTransactionMessageFeePayerSigner(payer, message);
message = setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, message);
message = appendTransactionMessageInstruction(
getTransferSolInstruction({
source: payer,
destination: address("11111111111111111111111111111111"),
amount: 1_000n,
}),
message,
);
const signed = await signTransactionMessageWithSigners(message);
const sig = getSignatureFromTransaction(signed);
await rpc.sendTransaction(signed, { encoding: "base64" }).send();
console.log(sig);What this demonstrates:
- Functional pipeline composes transaction messages immutably.
- Signers are explicit key pair adapters.
- System program helpers come from
@solana-program/*packages. - RPC uses
.send()for typed responses.
Deep Dive
How It Works
- kit splits subpath exports (
@solana/rpc,@solana/transaction-messages, codecs). - Codama reads IDL, builds a node graph, renders TypeScript client functions.
- gill re-exports kit + common program clients for faster app bootstrap.
- Wallet adapters integrate at signer layer - kit stays wallet-agnostic.
TypeScript / NPM Table
| Package | Role | Pin (this site) |
|---|---|---|
@solana/kit | RPC, messages, codecs, addresses | 7.0.0 |
gill | App-level helpers atop kit | Latest compatible with kit 7 |
@codama/cli | Codegen orchestration | Project-pinned |
@codama/renderers-js | TS client renderer | Matches CLI |
@solana-program/system | System ix helpers | Match kit major |
@solana-program/token | SPL Token ix helpers | Match token revision |
Rust Crate Table (parity)
| Crate | Role | When |
|---|---|---|
anchor-lang | IDL source | On-chain Anchor 0.32.1 |
solana-sdk | Rust client txs | Rust services |
declare_program! | Rust consumer IDL | Backend Rust |
TypeScript Notes
// Regenerate clients when IDL changes
// npx codama run --config codama.json
// Prefer bigint lamports in kit examples
const amount = 1_000_000n;Gotchas
- Mixing web3.js v1 and kit types - duplicate Pubkey models. Fix: migrate modules wholesale per route.
- Stale Codama output after IDL change - runtime encode errors. Fix: CI fails if generated folder dirty.
- Missing signer on message - simulation fails. Fix:
setTransactionMessageFeePayerSigner+ required signers. - Assuming gill replaces kit - gill is sugar; understand kit for edge cases. Fix: read underlying kit APIs.
- Wrong RPC feature support - DAS and priority fee APIs vary by provider. Fix: capability matrix per vendor.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
@coral-xyz/anchor TS | Legacy Anchor apps | Greenfield kit projects |
@solana/web3.js v1 | Maintaining old code | New 2026+ apps |
solana-py / AnchorPy | Python backends | Browser wallets |
Rust solana-client | High-throughput signer service | Frontend |
FAQs
Is web3.js deprecated?
Treated as legacy; kit is the recommended path for new TypeScript.
Codama with native IDL?
Yes if you publish Shank/Anchor-compatible IDL JSON.
Next.js App Router?
Keep signers browser-only; server routes build unsigned msgs or use server keypairs carefully.
Wallet Standard?
Integrate wallet adapters that expose kit-compatible signers.
Versioned transactions?
Default in kit examples - use v0 messages with ALTs when needed.
Priority fees in kit?
Append compute budget instructions from @solana-program/compute-budget.
gill vs kit?
Start with gill for speed; drop to kit for fine control.
Testing?
Bankrun TS or Surfpool-backed integration tests with kit clients.
ESM only?
Follow kit package exports; configure bundler for Node ESM in API routes.
Anchor version?
IDL from Anchor CLI 0.32.1 / anchor-lang 0.32.1 for Codama compatibility.
Related
- @solana/kit Basics - kit primer
- Codama - codegen pipeline
- gill - gill helpers
- Generating TS Clients - workflow
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.