@buckspay/react wraps the core client in idiomatic hooks. Wrap your component tree once with
BuckspayProvider; every component inside can then connect a wallet and send gasless payments
with two hooks.
Place
BuckspayProvider at the root of the tree (or the subtree that needs payment). Pass a
BuckspayConfig and a simulator context so useStellarPay().pay() can simulate the transaction
before signing.import { BuckspayProvider } from "@buckspay/react";
import { createBuckspayClient, createRpcSimContext } from "@buckspay/core";
import { classicAccount } from "@buckspay/accounts/classic";
import { walletsKit } from "@buckspay/signers/wallets-kit";
import { buckspayFacilitator } from "@buckspay/relayer/buckspay-facilitator";
const config = {
network: "testnet",
account: classicAccount(),
signer: walletsKit({ network: "testnet" }),
relayer: buckspayFacilitator({ url: "/api/gasless", network: "testnet" }),
gas: { mode: "sponsored" as const }
};
export function App() {
return (
<BuckspayProvider config={config} sim={createRpcSimContext("https://soroban-testnet.stellar.org")}>
{/* your app */}
</BuckspayProvider>
);
}
Pass
sim (a createRpcSimContext(rpcUrl)) so pay() can record authorization entries
against the Soroban RPC. Omit it only in connect-only apps that never call pay().useWallet() returns { wallet, address, connect, status, error }. Gate the payment UI on
wallet !== null:import { useWallet } from "@buckspay/react";
function ConnectButton() {
const { wallet, connect, status } = useWallet();
if (wallet) return null;
return (
<button onClick={() => void connect()} disabled={status === "connecting"} aria-live="polite">
{status === "connecting" ? "Connecting..." : "Connect wallet"}
</button>
);
}
pay(calls) - one-shot: prepare -> sign -> send in a single call.prepare(calls) / sign(intent) - split flow for apps that validate the signed intent in a
BFF before sending. See Facilitator and BFF.reset() - returns the store to idle so the user can retry.Full example
The component below is the compiled, type-checked reference implementation.Next
React Native
The same hooks on iOS and Android, with
nativePasskey and secure-storage adapters.Next.js BFF
Route factories that keep the API key server-side.

