React Hooks

useAuthenticationMethod

The useAuthenticationMethod hook is designed to retrieve the user's authentication method from their session. This hook is particularly useful when you need to determine how a user authenticated, whether via email, Google, Facebook, etc.

Example

import { useAuthenticationMethod } from '@futureverse/react'

const MyComponent = () => {
  const authenticationMethod = useAuthenticationMethod()

  if (!authenticationMethod) {
    return <div>No authentication method found</div>
  }

  return (
    <div>
      <p>Authentication Method: {authenticationMethod.method}</p>
      {authenticationMethod.email && <p>Email: {authenticationMethod.email}</p>}
      {authenticationMethod.eoa && <p>EOA: {authenticationMethod.eoa}</p>}
      {authenticationMethod.rAddress && <p>rAddress: {authenticationMethod.rAddress}</p>}
    </div>
  )
}

Return Type

The returned object can have different structures based on the authentication method used:

  • For 'fv:email', it includes the method and email:

    {
      "method": "fv:email",
      "email": "user@example.com"
    }
  • For 'fv:google' and 'fv:facebook', it includes the method and email:

    {
      "method": "fv:google" | "fv:facebook",
      "email": "user@example.com" // Email is added back to the object
    }
  • For 'wagmi', it includes the method and EOA (Ethereum address):

    {
      "method": "wagmi",
      "eoa": "0x1234567890abcdef1234567890abcdef12345678"
    }
  • For 'xaman', it includes the method and rAddress:

    {
      "method": "xaman",
      "rAddress": "rExampleAddress"
    }

Last updated

Feedback

Docs

© 2023 -> ♾️