Function.useKeybanClient
function useKeybanClient(): KeybanClient
Hook to access the Keyban SDK functionalities within a React component.
The useKeybanClient
hook allows you to access the initialized Keyban client,
enabling direct interaction with the SDK from functional React components. This hook
ensures that the Keyban client is available within the application's context and allows
you to utilize features such as account management, transactions, and blockchain queries.
Returns
The initialized Keyban client.
Throws
If the hook is used outside of a KeybanProvider, indicating that the context is not properly configured to provide the Keyban client.
Example
import React from 'react';
import { useKeybanClient } from "@keyban/sdk-react";
const MyComponent: React.FC = () => {
const keybanClient = useKeybanClient();
const handleCheckStatus = async () => {
try {
const status = await keybanClient.apiStatus();
console.log(`Keyban API Status: ${status}`);
} catch (error) {
console.error("Error checking Keyban API status:", error);
}
};
return (
<div>
<button onClick={handleCheckStatus}>Check API Status</button>
</div>
);
};
export default MyComponent;
See
- KeybanClient For more details on the Keyban client.
- KeybanProvider To understand how to set up the Keyban SDK context in your application.