Mobile (WalletConnect)
connect
Start a new WalletConnect session with Joey.
connect opens the connect modal (Reown AppKit, with Joey featured first) and resolves once the user approves in Joey.
const { actions } = useProvider();
const { data, error } = await actions.connect();
Parameters (optional)
{
chain?: string; // e.g. 'xrpl:0'
pairing?: { topic: string }; // reuse an existing pairing
openModal?: boolean; // default true; false to use your own UI
}
Returns
Promise<{
data: SessionTypes.Struct | null; // the new WalletConnect session
error: Error | null;
}>
Example
'use client';
import { useProvider } from './provider';
export function ConnectButton() {
const { actions, session, accounts } = useProvider();
const handleConnect = async () => {
const { error } = await actions.connect();
if (error) throw error;
};
if (session) {
return (
<div>
<p>Connected</p>
{accounts?.map((account) => <div key={account}>{account}</div>)}
</div>
);
}
return <button onClick={handleConnect}>Connect</button>;
}
Note
A Joey session covers the account and network that are active in Joey when the user approves. If the user switches either, Joey ends the session. See Events.