LazorKit LogoLazorKit
React Native SDK

useWallet

API reference for the useWallet hook.

useWallet

The useWallet hook provides methods to interact with the wallet on mobile.

import { useWallet } from '@lazorkit/wallet-mobile-adapter';

connect

Connects to the wallet, triggering a deep link to the portal if necessary.

Usage

const { connect } = useWallet();

await connect({ 
  redirectUrl: 'myapp://home',
  onSuccess: (wallet) => console.log('Connected:', wallet.smartWallet),
  onFail: (error) => console.error('Connection failed:', error)
});

Arguments

PropertyTypeRequiredDescription
optionsobjectYesConnection options.
options.redirectUrlstringYesApp deep link for callbacks.
options.onSuccess(wallet: WalletInfo) => voidNoCallback on success.
options.onFail(error: Error) => voidNoCallback on error.

disconnect

Disconnects the wallet session locally.

Usage

const { disconnect } = useWallet();
await disconnect({
  onSuccess: () => console.log('Disconnected'),
  onFail: (e) => console.error(e)
});

Arguments

PropertyTypeRequiredDescription
optionsobjectNoDisconnect options.
options.onSuccess() => voidNoCallback on success.
options.onFail(error: Error) => voidNoCallback on error.

signMessage

Signs a message via the portal.

Usage

const { signMessage } = useWallet();

await signMessage('Hello', { 
  redirectUrl: 'myapp://callback',
  onSuccess: (res) => console.log('Signature:', res.signature),
  onFail: (err) => console.error('Signing failed:', err)
});

Arguments

PropertyTypeRequiredDescription
messagestringYesMessage to sign.
optionsobjectYesOptions object.
options.redirectUrlstringYesApp deep link.
options.onSuccess(res: { signature: string }) => voidNoCallback on success.
options.onFail(error: Error) => voidNoCallback on error.

Returns

Promise<{ signature: string; signedPayload: string }> - Object containing the signature and signed payload.


signAndSendTransaction

Signs and sends a transaction.

Usage

Usage

const { signAndSendTransaction } = useWallet();

await signAndSendTransaction(
  {
    instructions: [/* ... */],
    transactionOptions: { 
      feeToken: 'USDC',
      computeUnitLimit: 500_000,
    }
  }, 
  { 
    redirectUrl: 'myapp://callback',
    onSuccess: (sig) => console.log('Tx Configured:', sig),
    onFail: (err) => console.error('Tx Failed:', err)
  }
);

Arguments

PropertyTypeRequiredDescription
payloadobjectYesTransaction payload.
payload.instructionsTransactionInstruction[]YesArray of instructions.
payload.transactionOptionsobjectYesConfig options.
transactionOptions.feeTokenstringNoToken address for gas fees (e.g. USDC).
transactionOptions.computeUnitLimitnumberNoMax compute units for the transaction.
transactionOptions.addressLookupTableAccountsAddressLookupTableAccount[]NoLookup tables for versioned (v0) transactions.
transactionOptions.clusterSimulation'devnet' | 'mainnet'YesNetwork to use for simulation.
optionsobjectYesOptions object.
options.redirectUrlstringYesApp deep link.
options.onSuccess(sig: string) => voidNoCallback on success.
options.onFail(error: Error) => voidNoCallback on error.

Returns

Promise<string> - The transaction signature.