JustaName React SDK
@justaname.id/react • Docs
JustaName React SDK
The JustaName React SDK makes it easy to integrate Ethereum Name Service (ENS) functionalities, including subname management, and user authentication via ENS into React applications. It simplifies interacting with ENS off-chain operations while ensuring secure and easy integration with your dApps.
Table of Contents
Installation
Install the JustaName React SDK using npm or yarn:
Usage
Setup with JustaNameProvider
JustaNameProvider
To use the JustaName React SDK, wrap your application with the JustaNameProvider
. This component provides all child components access to the JustaName context, enabling seamless interaction with ENS services.
Example: Setup with JustaNameProvider
JustaNameProvider
Example: Add a Subname
Below is a complete example of a React component where users can claim a subname using the useAddSubname
hook. It also checks subname availability with useIsSubnameAvailable
.
Hooks
The SDK offers various hooks for managing ENS accounts, subnames, and authentication.
Account and ENS Management
useAccountEnsNames
: Fetch ENS names associated with the user's account.useAddressEnsNames
: Fetch ENS names for a given Ethereum address.usePrimaryName
: Get the primary ENS name of an address.useAccountInvitations
: Get pending invitations for the connected account.useAccountSubnames
: Fetch all subnames for the connected account.
Subname Management
useIsSubnameAvailable
: Check if a subname is available.useAddSubname
: Add a new subname off-chain.useAcceptSubname
: Accept an invitation for a subname.useRejectSubname
: Reject a subname invitation.useRevokeSubname
: Revoke an issued subname.useUpdateSubname
: Update an ens metadata (off-chain and on-chain).useSearchSubnames
: Search for subnames based on given parameters.useSubname
: Get the details of a specific subname.useRecords
: Fetch records associated with any ENS name.
Authentication
useEnsSignIn
: Authenticate users with their ENS name.useEnsSignOut
: Sign out the connected user.useEnsAvatar
: Fetch the avatar of an ENS name.useEnsAuth
: Manage authentication state with ENS.
Other Hooks
useJustaName
: Access the JustaName context directly.useMounted
: Check if the component is mounted.useMountedAccount
: Get the mounted account details.useOffchainResolvers
: Fetch off-chain resolvers.useUpdateChanges
: Check for changes in the ENS metadata before updating.useUploadMedia
: Upload media for ENS metadata.
Contributing
Contributions are welcome! If you have suggestions or find issues, please open an issue or submit a pull request on the GitHub repository.
Last updated