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

# Solana Kit integration

> Use Cloak SDK from apps that standardize on @solana/kit

If your app stack is built around `@solana/kit`, you can still use Cloak SDK today.

Current state:

* Use Kit for RPC reads, subscriptions, and signer architecture.
* Use a thin `@solana/web3.js` bridge for Cloak transaction calls (`transact`, `partialWithdraw`, `swapWithChange`, etc.).

## Install

```bash theme={null}
npm install @cloak.dev/sdk @solana/web3.js @solana/kit
```

## Minimal bridge pattern

```typescript theme={null}
import {
  CLOAK_PROGRAM_ID,
  createUtxo,
  createZeroUtxo,
  generateUtxoKeypair,
  partialWithdraw,
  transact,
} from "@cloak.dev/sdk";
import { address, createSolanaRpc } from "@solana/kit";
import { Connection, Keypair } from "@solana/web3.js";

const rpcUrl = process.env.SOLANA_RPC_URL!;
const programId = CLOAK_PROGRAM_ID;

// Kit client for read paths.
const kitRpc = createSolanaRpc(rpcUrl);

// web3 bridge for Cloak transaction paths.
const connection = new Connection(rpcUrl, "confirmed");
const signer = Keypair.fromSecretKey(/* Uint8Array secret key */);

const { value: before } = await kitRpc
  .getBalance(address(signer.publicKey.toBase58()))
  .send();

const owner = await generateUtxoKeypair();
const output = await createUtxo(20_000_000n, owner);

const deposit = await transact(
  {
    inputUtxos: [await createZeroUtxo()],
    outputUtxos: [output],
    externalAmount: 20_000_000n,
    depositor: signer.publicKey,
  },
  {
    connection,
    programId,
    depositorKeypair: signer,
  },
);

await partialWithdraw(
  deposit.outputUtxos,
  Keypair.generate().publicKey,
  5_000_000n,
  {
    connection,
    programId,
    depositorKeypair: signer,
    cachedMerkleTree: deposit.merkleTree,
  },
);

const { value: after } = await kitRpc
  .getBalance(address(signer.publicKey.toBase58()))
  .send();
console.log(before.toString(), after.toString());
```

## Related examples

Use the concise snippets in [Code Examples](/sdk/examples), then adapt them to your Kit app runtime.
