Disconnect

The provider comes with a disconnect action that disconnects from the active session (if connected).

// Some where within your codebase...

const { actions, session, accounts } = useProvider();

const response = await actions.disconnect()

Example usage:

// File: ./src/app/component.tsx
'use client';

import * as React from 'react';
import { useProvider } from './page';

export default function Component() {
  const { actions, session, accounts } = useProvider();

  const handleDisconnect = async () => {
    await actions.disconnect();
    // You have been connected using wallet connect.
    // Now you can start interacting with the XRP Ledger.
    // ...
  };

  return (
    <div>
      {session && (
        <button type="button" onClick={handleDisconnect}>
          Disconnect
        </button>
      )}
    </div>
  );
}

Last updated