This page demonstrates how to use each method from the useMobileWallet hook. Make sure you have completed the Installation and Setup steps first.
Connect / Disconnect
Use connect to initiate a wallet connection and disconnect to end it. The account field contains the connected wallet’s public key.
import { useMobileWallet } from "@wallet-ui/react-native-web3js";
function ConnectButton() {
const { account, connect, disconnect } = useMobileWallet();
if (account) {
return <Button title="Disconnect" onPress={disconnect} />;
}
return <Button title="Connect Wallet" onPress={connect} />;
}
Sign Message
Use signMessage to request the wallet to sign an arbitrary byte payload. This is useful for off-chain signature verification.
import { useMobileWallet } from "@wallet-ui/react-native-web3js";
function SignMessageButton() {
const { signMessage } = useMobileWallet();
const handleSignMessage = async () => {
const message = "Verify this message";
const messageBytes = new TextEncoder().encode(message);
const signature = await signMessage(messageBytes);
console.log("Signature:", signature);
};
return <Button title="Sign Message" onPress={handleSignMessage} />;
}
Sign In with Solana (SIWS)
Use signIn to connect to a wallet and verify ownership in a single step. This combines authorization and message signing into one user interaction.
import { useMobileWallet } from "@wallet-ui/react-native-web3js";
function SignInButton() {
const { account, signIn } = useMobileWallet();
const handleSignIn = async () => {
await signIn({
domain: "your-app-domain.com",
statement: "Sign in to Your App",
});
console.log("Signed in:", account?.address);
};
return <Button title="Sign In" onPress={handleSignIn} />;
}
Sign and Send Transaction
Use signAndSendTransaction to request the wallet to sign a transaction and submit it to the Solana network.
import { useMobileWallet } from "@wallet-ui/react-native-web3js";
import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js";
function SendTransactionButton() {
const { account, signAndSendTransaction, connection } = useMobileWallet();
const handleSendTransaction = async () => {
if (!account) return;
const { blockhash } = await connection.getLatestBlockhash();
const transaction = new Transaction({
recentBlockhash: blockhash,
feePayer: new PublicKey(account.address),
}).add(
SystemProgram.transfer({
fromPubkey: new PublicKey(account.address),
toPubkey: new PublicKey("11111111111111111111111111111111"),
lamports: 1_000_000,
}),
);
const signature = await signAndSendTransaction(transaction);
console.log("Transaction signature:", signature);
};
return <Button title="Send Transaction" onPress={handleSendTransaction} />;
}
Next steps
Advanced: Invoke MWA Sessions Directly
Learn the low-level transact() API for direct MWA session control.
Sample Apps
Browse reference apps to jumpstart your development.
Last modified on May 27, 2026