useAirdrop

function useAirdrop(
    client,
): ActionResult<[Address, Lamports], Signature | undefined>;

Requests an airdrop of SOL to an address, as a reactive action.

Wraps client.airdrop with useAction: each dispatch(address, amount) runs the airdrop with a fresh AbortSignal and tracks its lifecycle through React state. Calling dispatch again while a previous airdrop is in flight aborts the first. This is a great fit for a devnet or localnet "fund this account" button, where the isRunning / data / error tracking drives the UI directly.

The airdrop capability is typically available on test networks (devnet, testnet) and local validators. Some implementations (e.g. LiteSVM) update balances directly without sending a transaction, in which case the resolved data is undefined rather than a Signature.

Parameters

ParameterTypeDescription
clientClientWithAirdropA client with an airdrop plugin installed (ClientWithAirdrop).

Returns

ActionResult<[Address, Lamports], Signature | undefined>

An ActionResult whose dispatch/dispatchAsync take the recipient address and the amount of lamports, and resolve with the transaction Signature, or undefined when the airdrop was performed without a transaction.

Example

import { useAirdrop } from '@solana/react';
import { lamports } from '@solana/kit';
 
function AirdropButton({ client, address }) {
    const { dispatch, isRunning } = useAirdrop(client);
    return (
        <button disabled={isRunning} onClick={() => dispatch(address, lamports(1_000_000_000n))}>
            {isRunning ? 'Airdropping…' : 'Airdrop 1 SOL'}
        </button>
    );
}

See

On this page