[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7A7RYBG6GV1BAWDZ2BHPNBG":3,"skill-same:01M7A7RYBG6GV1BAWDZ2BHPNBG":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":34,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M7A7RYBG6GV1BAWDZ2BHPNBG","solana-dev-frontend",null,"Build React and Next.js Solana apps with a Kit plugin client, Wallet Standard connection via @solana\u002Fkit-plugin-wallet (+ its React hooks), and @solana\u002Freact client bindings.","themusebook\u002Fskills","themusebook","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F349927247?v=4","01M7A5C1RV5S3V5FF6ZACVDNRN","musebook","01M7A5C1SFC3KRZAXNN60XJ7KM",0,"MIT","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fsolana-foundation\u002Ffrontend\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: solana-dev-frontend\ndescription: Build React and Next.js Solana apps with a Kit plugin client, Wallet Standard connection via @solana\u002Fkit-plugin-wallet (+ its React hooks), and @solana\u002Freact client bindings.\nlicense: MIT\nmetadata:\n  author: Solana Foundation\n  version: \"2.7.0\"\n  source: https:\u002F\u002Fgithub.com\u002Fsolana-foundation\u002Fsolana-dev-skill\n  category: Skill\n---\n\n# Frontend with Solana Kit\n\n> **Solana Foundation skill — mirrored in the Musebook skills hub.**\n> This entry reproduces, verbatim, the `frontend.md` reference of the\n> foundation-maintained **solana-dev** skill (v2.7.0, MIT) from\n> https:\u002F\u002Fgithub.com\u002Fsolana-foundation\u002Fsolana-dev-skill. It is one of the 16 topic\n> references the solana-dev router discloses progressively; for the full\n> skill (router + all references + nested guides), install the upstream\n> original: `npx skills add https:\u002F\u002Fgithub.com\u002Fsolana-foundation\u002Fsolana-dev-skill` — also mirrored in this hub as the\n> `solana-dev` entry. Maintained by the Solana Foundation; Musebook does\n> not author or maintain this content. Relative links in the body point\n> at the upstream skill's file layout and resolve in the full install.\n\n# Frontend with Solana Kit (Next.js \u002F React)\n\n## Goals\n- One Kit client instance for the app (RPC + wallet + transaction sending)\n- Wallet Standard-first discovery\u002Fconnect (no wallet-specific adapters)\n- Minimal \"use client\" footprint in Next.js (hooks only in leaf components)\n- Transaction sending that is observable, cancelable, and UX-friendly\n\n## Recommended dependencies\n- `@solana\u002Fkit` (8.3+)\n- `@solana\u002Fkit-plugin-rpc` (0.19+ — plans transaction v1), `@solana\u002Fkit-plugin-wallet` (0.20+ — reports wallet v1 support; wallet React hooks ship in `@solana\u002Fkit-plugin-wallet\u002Freact`)\n- `@solana\u002Freact` (8+ — Kit client bindings: `ClientProvider`, `useClient`, data hooks)\n- `swr` (peer dep of `@solana\u002Freact\u002Fswr`) or `@tanstack\u002Freact-query` (peer dep of `@solana\u002Freact\u002Fquery`) — pick whichever your app already uses\n- `@solana-program\u002Fsystem`, `@solana-program\u002Ftoken`, `@your-program\u002Fcodama-client` etc. (only what you need)\n\n`solanaRpc` already bundles transaction planning\u002Fsending — you do not need `@solana\u002Fkit-plugin-instruction-plan` in apps.\n\nDo **not** use `@solana\u002Fclient` \u002F `@solana\u002Freact-hooks` (framework-kit) for new work — that stack is stale; the maintained path is Kit plugins + `@solana\u002Freact`. Do not use `@solana\u002Fwallet-adapter-*` for new apps either; Wallet Standard discovery covers modern wallets.\n\n## Bootstrap recommendation\nPrefer `create-solana-dapp` and pick a Kit template for new projects.\n\n## Client setup (Next.js App Router)\n\nCreate a single wallet-backed client, export its type, and provide it via `ClientProvider` from `@solana\u002Freact`.\n\nExample `app\u002Fproviders.tsx`:\n\n```tsx\n'use client';\n\nimport React from 'react';\nimport { createClient } from '@solana\u002Fkit';\nimport { solanaRpc } from '@solana\u002Fkit-plugin-rpc';\nimport { walletSigner } from '@solana\u002Fkit-plugin-wallet';\nimport { ClientProvider } from '@solana\u002Freact';\n\nconst rpcUrl =\n  process.env.NEXT_PUBLIC_SOLANA_RPC_URL ?? 'https:\u002F\u002Fapi.devnet.solana.com';\n\n\u002F\u002F One client for the whole app. The connected wallet fills payer + identity.\n\u002F\u002F version: 1 — 4096-byte transactions, budget in message.config (see transactions-v1.md).\nexport const client = createClient()\n  .use(walletSigner({ chain: 'solana:devnet' }))\n  .use(solanaRpc({ rpcUrl, transactionConfig: { version: 1 } }));\n\n\u002F\u002F Export the client type so every useClient\u003CAppClient>() call in the app\n\u002F\u002F is fully typed (rpc, wallet, sendTransaction, ...).\nexport type AppClient = Awaited\u003Ctypeof client>;\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n  return \u003CClientProvider client={client}>{children}\u003C\u002FClientProvider>;\n}\n```\n\nThen wrap `app\u002Flayout.tsx` with `\u003CProviders>`.\n\n## Wallet connection\n\nUse the React hooks from `@solana\u002Fkit-plugin-wallet\u002Freact` — state hooks (`useWallets`, `useConnectedWallet`, `useWalletStatus`, `useIsWalletReady`), action hooks (`useConnect`, `useDisconnect`, `useSignIn`, `useSignMessage`), `useSelectAccount` (synchronous — returns the bound function, not an action), plus a `WalletReadyGate` component for the discovery warm-up. Every hook takes the wallet-enabled `client` as its first argument:\n\n```tsx\n'use client';\n\nimport {\n  useConnect,\n  useConnectedWallet,\n  useDisconnect,\n  useWallets,\n  WalletReadyGate,\n} from '@solana\u002Fkit-plugin-wallet\u002Freact';\nimport type { AppClient } from '.\u002Fproviders';\n\nfunction WalletButton({ client }: { client: AppClient }) {\n  const wallets = useWallets(client);\n  const connected = useConnectedWallet(client);\n  const { dispatch: connect } = useConnect(client);\n  const { dispatch: disconnect } = useDisconnect(client);\n\n  if (!connected) {\n    return wallets.map((wallet) => (\n      \u003Cbutton key={wallet.name} onClick={() => connect(wallet)}>\n        Connect {wallet.name}\n      \u003C\u002Fbutton>\n    ));\n  }\n  return (\n    \u003Cdiv>\n      \u003Cp>Connected: {connected.account.address}\u003C\u002Fp>\n      {!connected.supportedTransactionVersions.has(1) && (\n        \u003Cp>Update your wallet to send larger (v1) transactions.\u003C\u002Fp>\n      )}\n      \u003Cbutton onClick={() => disconnect()}>Disconnect\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  );\n}\n\n\u002F\u002F Hide wallet UI until Wallet Standard discovery settles\nexport const Wallet = ({ client }: { client: AppClient }) => (\n  \u003CWalletReadyGate client={client} fallback={\u003Cp>Loading wallets…\u003C\u002Fp>}>\n    \u003CWalletButton client={client} \u002F>\n  \u003C\u002FWalletReadyGate>\n);\n```\n\nOutside React (or for imperative flows), the same state is on the client: `client.wallet.getState()` returns `{ wallets, connected, status }` and `client.wallet.connect(wallet)` \u002F `disconnect()` \u002F `selectAccount(account)` drive the connection.\n\n### Transaction version support\n\n`connected.supportedTransactionVersions` (a `ReadonlySet\u003C'legacy' | 0 | 1>` from `@solana\u002Fkit-plugin-wallet` 0.20+) says what the connected wallet will sign. **Check `has(1)` before sending from a `version: 1` client** — a wallet that has not shipped v1 rejects the signing request. Two ways to handle a `false`:\n\n- Show an upgrade prompt (as above) and keep the action disabled. Simplest; right when your transactions genuinely need 4096 bytes.\n- Keep a second client with `transactionConfig: { version: 0 }` and route those users through it. Right when the transactions also fit in 1232 bytes.\n\nThe set is the intersection across the wallet's signing features, so a version appears only when every signing path accepts it. Wallets that predate versioned transactions report `Set(['legacy'])` — test membership, not emptiness. See [transactions-v1.md](transactions-v1.md#wallets).\n\n## Sending transactions\n\nWith the wallet plugin installed, `client.sendTransaction` plans a v1 transaction (per the client's `transactionConfig`), estimates its resource limits, asks the wallet to sign, and sends. Wrap it in `useSendTransaction` from `@solana\u002Freact` so pending\u002Ferror state, abort-on-resend, and stale-while-revalidate come for free instead of hand-rolled `useState`:\n\n```tsx\n'use client';\n\nimport { isAddress, sol, solToLamports } from '@solana\u002Fkit';\nimport { getTransferSolInstruction } from '@solana-program\u002Fsystem';\nimport { useConnectedWallet } from '@solana\u002Fkit-plugin-wallet\u002Freact';\nimport { useClient, useSendTransaction } from '@solana\u002Freact';\nimport type { AppClient } from '@\u002Fapp\u002Fproviders';\n\nfunction TipButton({ to }: { to: string }) {\n  const client = useClient\u003CAppClient>();\n  const connected = useConnectedWallet(client);\n  \u002F\u002F The client plans v1; a wallet that cannot sign v1 must not be asked to.\n  const canSendV1 = connected?.supportedTransactionVersions.has(1) ?? false;\n\n  \u002F\u002F Each dispatch gets a fresh AbortSignal; resending aborts the in-flight send\n  const { dispatch, isRunning, error, data } = useSendTransaction(client);\n  const signature = data?.context.signature;\n  const recipient = isAddress(to) ? to : null;\n\n  const tip = () => {\n    if (!recipient) return;\n    dispatch([\n      getTransferSolInstruction({\n        source: client.payer,\n        destination: recipient,\n        \u002F\u002F `sol()` returns a fixed-point value; instructions take Lamports\n        amount: solToLamports(sol('0.01')),\n      }),\n    ]);\n  };\n\n  return (\n    \u003C>\n      \u003Cbutton disabled={isRunning || !canSendV1 || !recipient} onClick={tip}>\n        {isRunning ? 'Sending…' : error ? 'Retry' : 'Tip 0.01 SOL'}\n      \u003C\u002Fbutton>\n      {signature ? \u003Ca href={`https:\u002F\u002Fexplorer.solana.com\u002Ftx\u002F${signature}`}>View\u003C\u002Fa> : null}\n    \u003C\u002F>\n  );\n}\n```\n\nUse `dispatch` in event handlers — it returns `void` and never throws, so it can't produce an unhandled rejection. Use `useSendTransactions` when the instructions may need splitting across transactions, and plain `useAction` for any other async flow (or a send wrapped in extra logic). Full hook semantics are in [kit\u002Freact.md](kit\u002Freact.md#useplantransaction--useplantransactions--usesendtransaction--usesendtransactions).\n\n## Data fetching and subscriptions\n\n`@solana\u002Freact` ships data hooks — `useRequest` (one-shot reads), `useSubscription` (websocket streams), `useTrackedData` (a one-shot read seeded into a subscription, slot-deduped), and `useAction` — plus adapters for SWR (`@solana\u002Freact\u002Fswr`) and TanStack Query (`@solana\u002Freact\u002Fquery`). Prefer these over hand-rolled polling, and always call `useClient\u003CAppClient>()` with your exported client type. See [kit\u002Freact.md](kit\u002Freact.md#data-hooks) for the per-hook return shapes and gotchas.\n\n**Balance and other live account data: use `useTrackedDataSWR`.** It fires the initial RPC fetch and the account subscription together, slot-dedupes them so an out-of-order arrival never regresses the displayed value, and routes the result through SWR's cache so every component on the same key shares one connection. A Next.js-shaped hook:\n\n```tsx\n'use client';\n\nimport { useMemo } from 'react';\nimport { type Address, type Lamports } from '@solana\u002Fkit';\nimport { useClient } from '@solana\u002Freact';\nimport { useTrackedDataSWR } from '@solana\u002Freact\u002Fswr';\nimport type { AppClient } from '@\u002Fapp\u002Fproviders';\n\nexport function useBalance(accountAddress?: Address) {\n  const { rpc, rpcSubscriptions } = useClient\u003CAppClient>();\n\n  \u002F\u002F Passing `null` when there is no address is what gates the hook off —\n  \u002F\u002F it must be memoized, since spec identity drives teardown and re-run.\n  const spec = useMemo(\n    () =>\n      accountAddress\n        ? {\n            initialValueSource: rpc.getBalance(accountAddress, { commitment: 'confirmed' }),\n            initialValueMapper: (lamports: Lamports) => lamports,\n            streamSource: rpcSubscriptions.accountNotifications(accountAddress, {\n              commitment: 'confirmed',\n            }),\n            streamValueMapper: ({ lamports }: { lamports: Lamports }) => lamports,\n          }\n        : null,\n    [rpc, rpcSubscriptions, accountAddress],\n  );\n\n  const { data, error } = useTrackedDataSWR(\n    accountAddress ? ['balance', accountAddress] : null,\n    spec,\n  );\n\n  return {\n    lamports: data?.value ?? null,\n    isLoading: accountAddress != null && data == null && error == null,\n    error,\n  };\n}\n```\n\n**Multi-cluster apps:** include the cluster in the cache key, and derive it from the same source that built the client — the client is typically rebuilt one render *after* the selection flips, so a key read from selection state binds the new network's fetch to the previous network's `rpc`. The [Kit example app](https:\u002F\u002Fgithub.com\u002Fanza-xyz\u002Fkit\u002Fblob\u002Fmain\u002Fexamples\u002Freact-app\u002Fsrc\u002Fcomponents\u002FBalance.tsx) stamps `chain` onto the client with `extendClient` and reads it back off `useClient\u003CAppClient>()` to keep the two in lockstep.\n\nRender lamports with the Kit helpers rather than dividing by `1e9`:\n\n```tsx\nimport { formatDecimalFixedPoint, lamportsToSol } from '@solana\u002Fkit';\n\nconst solFormatter = new Intl.NumberFormat(undefined, { maximumFractionDigits: 5 });\n\nfunction BalanceDisplay({ accountAddress }: { accountAddress: Address }) {\n  const { lamports } = useBalance(accountAddress);\n  if (lamports == null) return \u003Cspan>&ndash;\u003C\u002Fspan>;\n  return \u003Cspan>{formatDecimalFixedPoint(solFormatter, lamportsToSol(lamports))} ◎\u003C\u002Fspan>;\n}\n```\n\nFor Next.js: keep server components server-side; only leaf components that call hooks should be client components. Server-side reads can use a plain Kit RPC client (no wallet plugin).\n\n## Transaction UX checklist\n\n- Disable inputs while a transaction is pending\n- Provide a signature immediately after send\n- Track confirmation states (processed\u002Fconfirmed\u002Ffinalized) based on UX need\n- Gate v1 sends on `connected.supportedTransactionVersions.has(1)`; show an upgrade prompt otherwise\n- Show actionable errors:\n  - user rejected signing\n  - wallet does not support transaction v1 (upgrade the wallet)\n  - insufficient SOL for fees \u002F rent\n  - blockhash expired \u002F dropped\n  - account already in use \u002F already initialized\n  - program error (custom error code)\n\n## Legacy apps\n\n- App built on web3.js v1 + wallet-adapter? Migrate to web3.js v3 (Kit internals, same classes; 3.0 since Oct 2026) first — see [kit-web3-interop.md](kit-web3-interop.md) for routing to the official migration skill — then adopt Kit plugins incrementally.\n- Found `@solana\u002Fclient` \u002F `@solana\u002Freact-hooks` (framework-kit)? Migrate to the Kit plugin client + `@solana\u002Freact`: `createClient({ endpoint, walletConnectors })` becomes `createClient().use(walletSigner(...)).use(solanaRpc(...))`, and framework-kit hooks map to the `@solana\u002Fkit-plugin-wallet\u002Freact` hooks or `client.wallet` state.\n","# Frontend with Solana Kit\n\n> **Solana Foundation skill — mirrored in the Musebook skills hub.**\n> This entry reproduces, verbatim, the `frontend.md` reference of the\n> foundation-maintained **solana-dev** skill (v2.7.0, MIT) from\n> https:\u002F\u002Fgithub.com\u002Fsolana-foundation\u002Fsolana-dev-skill. It is one of the 16 topic\n> references the solana-dev router discloses progressively; for the full\n> skill (router + all references + nested guides), install the upstream\n> original: `npx skills add https:\u002F\u002Fgithub.com\u002Fsolana-foundation\u002Fsolana-dev-skill` — also mirrored in this hub as the\n> `solana-dev` entry. Maintained by the Solana Foundation; Musebook does\n> not author or maintain this content. Relative links in the body point\n> at the upstream skill's file layout and resolve in the full install.\n\n# Frontend with Solana Kit (Next.js \u002F React)\n\n## Goals\n- One Kit client instance for the app (RPC + wallet + transaction sending)\n- Wallet Standard-first discovery\u002Fconnect (no wallet-specific adapters)\n- Minimal \"use client\" footprint in Next.js (hooks only in leaf components)\n- Transaction sending that is observable, cancelable, and UX-friendly\n\n## Recommended dependencies\n- `@solana\u002Fkit` (8.3+)\n- `@solana\u002Fkit-plugin-rpc` (0.19+ — plans transaction v1), `@solana\u002Fkit-plugin-wallet` (0.20+ — reports wallet v1 support; wallet React hooks ship in `@solana\u002Fkit-plugin-wallet\u002Freact`)\n- `@solana\u002Freact` (8+ — Kit client bindings: `ClientProvider`, `useClient`, data hooks)\n- `swr` (peer dep of `@solana\u002Freact\u002Fswr`) or `@tanstack\u002Freact-query` (peer dep of `@solana\u002Freact\u002Fquery`) — pick whichever your app already uses\n- `@solana-program\u002Fsystem`, `@solana-program\u002Ftoken`, `@your-program\u002Fcodama-client` etc. (only what you need)\n\n`solanaRpc` already bundles transaction planning\u002Fsending — you do not need `@solana\u002Fkit-plugin-instruction-plan` in apps.\n\nDo **not** use `@solana\u002Fclient` \u002F `@solana\u002Freact-hooks` (framework-kit) for new work — that stack is stale; the maintained path is Kit plugins + `@solana\u002Freact`. Do not use `@solana\u002Fwallet-adapter-*` for new apps either; Wallet Standard discovery covers modern wallets.\n\n## Bootstrap recommendation\nPrefer `create-solana-dapp` and pick a Kit template for new projects.\n\n## Client setup (Next.js App Router)\n\nCreate a single wallet-backed client, export its type, and provide it via `ClientProvider` from `@solana\u002Freact`.\n\nExample `app\u002Fproviders.tsx`:\n\n```tsx\n'use client';\n\nimport React from 'react';\nimport { createClient } from '@solana\u002Fkit';\nimport { solanaRpc } from '@solana\u002Fkit-plugin-rpc';\nimport { walletSigner } from '@solana\u002Fkit-plugin-wallet';\nimport { ClientProvider } from '@solana\u002Freact';\n\nconst rpcUrl =\n  process.env.NEXT_PUBLIC_SOLANA_RPC_URL ?? 'https:\u002F\u002Fapi.devnet.solana.com';\n\n\u002F\u002F One client for the whole app. The connected wallet fills payer + identity.\n\u002F\u002F version: 1 — 4096-byte transactions, budget in message.config (see transactions-v1.md).\nexport const client = createClient()\n  .use(walletSigner({ chain: 'solana:devnet' }))\n  .use(solanaRpc({ rpcUrl, transactionConfig: { version: 1 } }));\n\n\u002F\u002F Export the client type so every useClient\u003CAppClient>() call in the app\n\u002F\u002F is fully typed (rpc, wallet, sendTransaction, ...).\nexport type AppClient = Awaited\u003Ctypeof client>;\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n  return \u003CClientProvider client={client}>{children}\u003C\u002FClientProvider>;\n}\n```\n\nThen wrap `app\u002Flayout.tsx` with `\u003CProviders>`.\n\n## Wallet connection\n\nUse the React hooks from `@solana\u002Fkit-plugin-wallet\u002Freact` — state hooks (`useWallets`, `useConnectedWallet`, `useWalletStatus`, `useIsWalletReady`), action hooks (`useConnect`, `useDisconnect`, `useSignIn`, `useSignMessage`), `useSelectAccount` (synchronous — returns the bound function, not an action), plus a `WalletReadyGate` component for the discovery warm-up. Every hook takes the wallet-enabled `client` as its first argument:\n\n```tsx\n'use client';\n\nimport {\n  useConnect,\n  useConnectedWallet,\n  useDisconnect,\n  useWallets,\n  WalletReadyGate,\n} from '@solana\u002Fkit-plugin-wallet\u002Freact';\nimport type { AppClient } from '.\u002Fproviders';\n\nfunction WalletButton({ client }: { client: AppClient }) {\n  const wallets = useWallets(client);\n  const connected = useConnectedWallet(client);\n  const { dispatch: connect } = useConnect(client);\n  const { dispatch: disconnect } = useDisconnect(client);\n\n  if (!connected) {\n    return wallets.map((wallet) => (\n      \u003Cbutton key={wallet.name} onClick={() => connect(wallet)}>\n        Connect {wallet.name}\n      \u003C\u002Fbutton>\n    ));\n  }\n  return (\n    \u003Cdiv>\n      \u003Cp>Connected: {connected.account.address}\u003C\u002Fp>\n      {!connected.supportedTransactionVersions.has(1) && (\n        \u003Cp>Update your wallet to send larger (v1) transactions.\u003C\u002Fp>\n      )}\n      \u003Cbutton onClick={() => disconnect()}>Disconnect\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  );\n}\n\n\u002F\u002F Hide wallet UI until Wallet Standard discovery settles\nexport const Wallet = ({ client }: { client: AppClient }) => (\n  \u003CWalletReadyGate client={client} fallback={\u003Cp>Loading wallets…\u003C\u002Fp>}>\n    \u003CWalletButton client={client} \u002F>\n  \u003C\u002FWalletReadyGate>\n);\n```\n\nOutside React (or for imperative flows), the same state is on the client: `client.wallet.getState()` returns `{ wallets, connected, status }` and `client.wallet.connect(wallet)` \u002F `disconnect()` \u002F `selectAccount(account)` drive the connection.\n\n### Transaction version support\n\n`connected.supportedTransactionVersions` (a `ReadonlySet\u003C'legacy' | 0 | 1>` from `@solana\u002Fkit-plugin-wallet` 0.20+) says what the connected wallet will sign. **Check `has(1)` before sending from a `version: 1` client** — a wallet that has not shipped v1 rejects the signing request. Two ways to handle a `false`:\n\n- Show an upgrade prompt (as above) and keep the action disabled. Simplest; right when your transactions genuinely need 4096 bytes.\n- Keep a second client with `transactionConfig: { version: 0 }` and route those users through it. Right when the transactions also fit in 1232 bytes.\n\nThe set is the intersection across the wallet's signing features, so a version appears only when every signing path accepts it. Wallets that predate versioned transactions report `Set(['legacy'])` — test membership, not emptiness. See [transactions-v1.md](transactions-v1.md#wallets).\n\n## Sending transactions\n\nWith the wallet plugin installed, `client.sendTransaction` plans a v1 transaction (per the client's `transactionConfig`), estimates its resource limits, asks the wallet to sign, and sends. Wrap it in `useSendTransaction` from `@solana\u002Freact` so pending\u002Ferror state, abort-on-resend, and stale-while-revalidate come for free instead of hand-rolled `useState`:\n\n```tsx\n'use client';\n\nimport { isAddress, sol, solToLamports } from '@solana\u002Fkit';\nimport { getTransferSolInstruction } from '@solana-program\u002Fsystem';\nimport { useConnectedWallet } from '@solana\u002Fkit-plugin-wallet\u002Freact';\nimport { useClient, useSendTransaction } from '@solana\u002Freact';\nimport type { AppClient } from '@\u002Fapp\u002Fproviders';\n\nfunction TipButton({ to }: { to: string }) {\n  const client = useClient\u003CAppClient>();\n  const connected = useConnectedWallet(client);\n  \u002F\u002F The client plans v1; a wallet that cannot sign v1 must not be asked to.\n  const canSendV1 = connected?.supportedTransactionVersions.has(1) ?? false;\n\n  \u002F\u002F Each dispatch gets a fresh AbortSignal; resending aborts the in-flight send\n  const { dispatch, isRunning, error, data } = useSendTransaction(client);\n  const signature = data?.context.signature;\n  const recipient = isAddress(to) ? to : null;\n\n  const tip = () => {\n    if (!recipient) return;\n    dispatch([\n      getTransferSolInstruction({\n        source: client.payer,\n        destination: recipient,\n        \u002F\u002F `sol()` returns a fixed-point value; instructions take Lamports\n        amount: solToLamports(sol('0.01')),\n      }),\n    ]);\n  };\n\n  return (\n    \u003C>\n      \u003Cbutton disabled={isRunning || !canSendV1 || !recipient} onClick={tip}>\n        {isRunning ? 'Sending…' : error ? 'Retry' : 'Tip 0.01 SOL'}\n      \u003C\u002Fbutton>\n      {signature ? \u003Ca href={`https:\u002F\u002Fexplorer.solana.com\u002Ftx\u002F${signature}`}>View\u003C\u002Fa> : null}\n    \u003C\u002F>\n  );\n}\n```\n\nUse `dispatch` in event handlers — it returns `void` and never throws, so it can't produce an unhandled rejection. Use `useSendTransactions` when the instructions may need splitting across transactions, and plain `useAction` for any other async flow (or a send wrapped in extra logic). Full hook semantics are in [kit\u002Freact.md](kit\u002Freact.md#useplantransaction--useplantransactions--usesendtransaction--usesendtransactions).\n\n## Data fetching and subscriptions\n\n`@solana\u002Freact` ships data hooks — `useRequest` (one-shot reads), `useSubscription` (websocket streams), `useTrackedData` (a one-shot read seeded into a subscription, slot-deduped), and `useAction` — plus adapters for SWR (`@solana\u002Freact\u002Fswr`) and TanStack Query (`@solana\u002Freact\u002Fquery`). Prefer these over hand-rolled polling, and always call `useClient\u003CAppClient>()` with your exported client type. See [kit\u002Freact.md](kit\u002Freact.md#data-hooks) for the per-hook return shapes and gotchas.\n\n**Balance and other live account data: use `useTrackedDataSWR`.** It fires the initial RPC fetch and the account subscription together, slot-dedupes them so an out-of-order arrival never regresses the displayed value, and routes the result through SWR's cache so every component on the same key shares one connection. A Next.js-shaped hook:\n\n```tsx\n'use client';\n\nimport { useMemo } from 'react';\nimport { type Address, type Lamports } from '@solana\u002Fkit';\nimport { useClient } from '@solana\u002Freact';\nimport { useTrackedDataSWR } from '@solana\u002Freact\u002Fswr';\nimport type { AppClient } from '@\u002Fapp\u002Fproviders';\n\nexport function useBalance(accountAddress?: Address) {\n  const { rpc, rpcSubscriptions } = useClient\u003CAppClient>();\n\n  \u002F\u002F Passing `null` when there is no address is what gates the hook off —\n  \u002F\u002F it must be memoized, since spec identity drives teardown and re-run.\n  const spec = useMemo(\n    () =>\n      accountAddress\n        ? {\n            initialValueSource: rpc.getBalance(accountAddress, { commitment: 'confirmed' }),\n            initialValueMapper: (lamports: Lamports) => lamports,\n            streamSource: rpcSubscriptions.accountNotifications(accountAddress, {\n              commitment: 'confirmed',\n            }),\n            streamValueMapper: ({ lamports }: { lamports: Lamports }) => lamports,\n          }\n        : null,\n    [rpc, rpcSubscriptions, accountAddress],\n  );\n\n  const { data, error } = useTrackedDataSWR(\n    accountAddress ? ['balance', accountAddress] : null,\n    spec,\n  );\n\n  return {\n    lamports: data?.value ?? null,\n    isLoading: accountAddress != null && data == null && error == null,\n    error,\n  };\n}\n```\n\n**Multi-cluster apps:** include the cluster in the cache key, and derive it from the same source that built the client — the client is typically rebuilt one render *after* the selection flips, so a key read from selection state binds the new network's fetch to the previous network's `rpc`. The [Kit example app](https:\u002F\u002Fgithub.com\u002Fanza-xyz\u002Fkit\u002Fblob\u002Fmain\u002Fexamples\u002Freact-app\u002Fsrc\u002Fcomponents\u002FBalance.tsx) stamps `chain` onto the client with `extendClient` and reads it back off `useClient\u003CAppClient>()` to keep the two in lockstep.\n\nRender lamports with the Kit helpers rather than dividing by `1e9`:\n\n```tsx\nimport { formatDecimalFixedPoint, lamportsToSol } from '@solana\u002Fkit';\n\nconst solFormatter = new Intl.NumberFormat(undefined, { maximumFractionDigits: 5 });\n\nfunction BalanceDisplay({ accountAddress }: { accountAddress: Address }) {\n  const { lamports } = useBalance(accountAddress);\n  if (lamports == null) return \u003Cspan>&ndash;\u003C\u002Fspan>;\n  return \u003Cspan>{formatDecimalFixedPoint(solFormatter, lamportsToSol(lamports))} ◎\u003C\u002Fspan>;\n}\n```\n\nFor Next.js: keep server components server-side; only leaf components that call hooks should be client components. Server-side reads can use a plain Kit RPC client (no wallet plugin).\n\n## Transaction UX checklist\n\n- Disable inputs while a transaction is pending\n- Provide a signature immediately after send\n- Track confirmation states (processed\u002Fconfirmed\u002Ffinalized) based on UX need\n- Gate v1 sends on `connected.supportedTransactionVersions.has(1)`; show an upgrade prompt otherwise\n- Show actionable errors:\n  - user rejected signing\n  - wallet does not support transaction v1 (upgrade the wallet)\n  - insufficient SOL for fees \u002F rent\n  - blockhash expired \u002F dropped\n  - account already in use \u002F already initialized\n  - program error (custom error code)\n\n## Legacy apps\n\n- App built on web3.js v1 + wallet-adapter? Migrate to web3.js v3 (Kit internals, same classes; 3.0 since Oct 2026) first — see [kit-web3-interop.md](kit-web3-interop.md) for routing to the official migration skill — then adopt Kit plugins incrementally.\n- Found `@solana\u002Fclient` \u002F `@solana\u002Freact-hooks` (framework-kit)? Migrate to the Kit plugin client + `@solana\u002Freact`: `createClient({ endpoint, walletConnectors })` becomes `createClient().use(walletSigner(...)).use(solanaRpc(...))`, and framework-kit hooks map to the `@solana\u002Fkit-plugin-wallet\u002Freact` hooks or `client.wallet` state.\n",{"name":5,"license":15,"metadata":24,"description":7},{"author":25,"source":26,"version":27,"category":28},"Solana Foundation","https:\u002F\u002Fgithub.com\u002Fsolana-foundation\u002Fsolana-dev-skill","2.7.0","Skill","main","1c523aba5cdf867a79f078847075492d7778092a","public\u002Fapi\u002Fskills\u002Fsolana-foundation\u002Ffrontend",1,"https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills","https:\u002F\u002Fskills.x402.wtf","https:\u002F\u002Fgithub.com\u002Fthemusebook","https:\u002F\u002Fmusebook.trade","The official Github of musebook","2026-11-02 23:42:26",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add themusebook\u002Fskills --skill solana-dev-frontend",{"tool":45,"command":46},"bunx","bunx skills add themusebook\u002Fskills --skill solana-dev-frontend",{"tool":48,"command":49},"pnpm","pnpm dlx skills add themusebook\u002Fskills --skill solana-dev-frontend","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fsolana-foundation\u002Ffrontend\u002FSKILL.md",true,[53,59],{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"metadata.json","REFERENCE","参考文档",370,"https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fsolana-foundation\u002Ffrontend\u002Fmetadata.json",{"path":60,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":61,"sourceHtmlUrl":62},"verification.json",1072,"https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fsolana-foundation\u002Ffrontend\u002Fverification.json",[64,72,79,86,93,100],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7AB34SPKVSDRRG009PM1CZH","youtube-clipper","YouTube 视频智能剪辑工具。下载视频和字幕，AI 分析生成精细章节（几分钟级别）， 用户选择片段后自动剪辑、翻译字幕为中英双语、烧录字幕到视频，并生成总结文案。 使用场景：当用户需要剪辑 YouTube 视频、生成短视频片段、制作双语字幕版本时。 关键词：视频剪辑、YouTube、字幕翻译、双语字幕、视频下载、clip video","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M7AB18BH6N7KR7939HRNWVMQ","viem-integration","Integrate EVM blockchains using viem. Use when user says \"read blockchain data\", \"send transaction\", \"interact with smart contract\", \"connect to Ethereum\", \"use viem\", \"use wagmi\", \"wallet integration\", \"viem setup\", or mentions blockchain\u002FEVM development with TypeScript.","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fviem-integration\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7AB12GHGP48WCNXDQQ9222H","v4-security-foundations","Security-first Uniswap v4 hook development. Use when user mentions \"v4 hooks\", \"hook security\", \"PoolManager\", \"beforeSwap\", \"afterSwap\", or asks about V4 hook best practices, vulnerabilities, or audit requirements.","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fv4-security-foundations\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7AB0XM3PSR7V3Q2ZRR0Q0FB","v4-sdk-integration","App-layer SDK guide for building swap and liquidity experiences directly with the Uniswap v4 SDK. Use when user asks about \"v4 sdk\", \"uniswap v4\", \"v4 swap\", \"v4 liquidity\", \"PoolManager\", \"V4Planner\", \"StateView\", \"PositionManager\", \"pool state\", \"v4 position\", \"uniswap sdk\", or when building swap\u002Fliquidity UX directly with SDKs rather than via the Trading API.","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fv4-sdk-integration\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M7AB0SGA93ASA588DJW4P9WT","v4-hook-generator","Generate Uniswap v4 hook contracts via OpenZeppelin MCP. Use when building custom swap logic, async swaps, hook-owned liquidity, custom curves, dynamic fees, MEV protection, limit orders, or oracle hooks.","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fv4-hook-generator\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M7AAZYH75H4CS03WSW2EZ8DM","testing","For testing with Light Protocol programs and clients on localnet, devnet, and mainnet validation.","https:\u002F\u002Fgithub.com\u002Fthemusebook\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002FSKILL.md",[],[]]