useFlowAccount

useFlowAccount

Hook for managing and accessing Flow blockchain account information within a React application.

Import

import { useFlowAccount } from '@doodlesteam/flooks';

Usage

const MyComponent = () => {
  const { address } = useFlowAccount({
    onConnect: ({ address }) => console.log(`Connected: ${address}`),
    onDisconnect: () => console.log('Disconnected'),
  });
 
  return <div>User's Flow Address: {address}</div>;
};

API Reference

Props

useFlowAccount accepts an optional UseFlowAccountProps object:

  • onConnect: Callback function triggered when a user connects their Flow account. It receives an object containing the user's address.
  • onDisconnect: Callback function triggered when a user disconnects their Flow account.

Example

const { address } = useFlowAccount({
  onConnect: ({ address }) => console.log(`Connected: ${address}`),
  onDisconnect: () => console.log('Disconnected'),
});

Return Value

The hook returns a FlowAccount object:

  • address: The connected user's Flow blockchain address as a string, if available.