useEnsAuth
Usage
import { useEnsAuth } from '@justaname.id/react'
function EnsAuthComponent() {
const {
isLoggedIn,
connectedEns,
isEnsAuthPending,
isEnsAuthFetching,
isEnsAuthLoading,
refreshEnsAuth
} = useEnsAuth({
backendUrl: 'https://api.justaname.id',
currentEnsRoute: '/auth/current-ens',
enabled: true,
local: false
})
if (isEnsAuthLoading) return <div>Checking authentication...</div>
return (
<div>
{isLoggedIn && connectedEns ? (
<div>
<p>Welcome, {connectedEns.ens}!</p>
<p>Address: {connectedEns.address}</p>
<p>Chain ID: {connectedEns.chainId}</p>
<button onClick={refreshEnsAuth}>Refresh Auth</button>
</div>
) : (
<div>
<p>Not authenticated</p>
<button onClick={refreshEnsAuth}>Check Auth Status</button>
</div>
)}
</div>
)
}Returns
Parameters
Type Parameters
Defined in
Last updated