GitHub - Kronos-Guild/framework-kit: Framework for Solana dApps: orchestrates wallets, transactions, and reactive freshness-aware data flows out of the box. (original) (raw)

Framework-kit Hero

codecov

@solana/client: npm version npm bundle size npm downloads

@solana/react-hooks: npm version npm bundle size npm downloads

React hooks for Solana. Connect wallets, fetch balances, and send transactions with minimal setup.

Why Framework-kit?

Building Solana dApps usually means wiring together RPC connections, wallet adapters, and state management yourself. Framework-kit handles this for you:

Packages

Examples

Install

npm install @solana/client @solana/react-hooks

React quick start

Add this to your main App file (e.g., App.tsx). You'll need a Solana wallet extension like Phantom installed in your browser.

import { autoDiscover, createClient } from "@solana/client"; import { SolanaProvider, useWalletConnection } from "@solana/react-hooks";

// Create a client pointing to Solana devnet const client = createClient({ endpoint: "https://api.devnet.solana.com", walletConnectors: autoDiscover(), // Finds installed wallet extensions });

function WalletButtons() { // This hook gives you everything you need for wallet connection const { connectors, connect, connecting } = useWalletConnection(); return ( <> {connectors.map((connector) => ( <button key={connector.id} disabled={connecting} onClick={() => connect(connector.id)} > {connector.name} ))} </> ); }

export function App() { return ( ); }

Run your app and you should see buttons for each detected wallet. Click one to connect.

Next.js note: Components using these hooks must be marked with 'use client' at the top of the file.

Learn more