
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@justaname.id/react
Advanced tools
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 ensuri
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.
Install the JustaName React SDK using npm or yarn:
npm install @justaname.id/react
# or
yarn add @justaname.id/react
JustaNameProviderTo 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.
JustaNameProvidertsx
'use client';
import { JustaNameProvider } from '@justaname.id/react';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { publicProvider } from 'wagmi/providers/public';
import { getDefaultWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit';
import '@rainbow-me/rainbowkit/styles.css';
import { AddSubname } from './AddSubname';
const { wallets } = getDefaultWallets();
const config = getDefaultConfig({
appName: 'JustaName Console',
projectId: 'YOUR_PROJECT_ID',
wallets: [
...wallets,
{
groupName: 'Other',
wallets: [argentWallet, trustWallet, ledgerWallet],
},
],
chains: [mainnet, sepolia],
ssr: true,
});
const justaNameConfig = {
networks: [{ chainId: 1, providerUrl: 'https://mainnet.infura.io/v3/YOUR_INFURA_KEY' }],
ensDomains: [
{
chainId: 1,
domain: 'your_ens_domain.eth',
apiKey: 'your-api-key' // Not recommended for production, use a backend server to protect your API key
}
],
backendUrl: 'https://your-backend-url.com' // Leave empty for same origin (e.g when using Next.js)
};
export const App = () => {
return (
<WagmiConfig client={config}>
<RainbowKitProvider chains={chains}>
<JustaNameProvider config={justaNameConfig}>
<AddSubname />
</JustaNameProvider>
</RainbowKitProvider>
</WagmiConfig>
);
}
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.
tsx
Copy code
import { useAddSubname, useIsSubnameAvailable } from '@justaname.id/react';
import { useState } from 'react';
import { useDebounce } from '@uidotdev/usehooks';
import { ConnectButton } from '@rainbow-me/rainbowkit';
import { useAccount } from 'wagmi';
export const AddSubname = () => {
const { isConnected } = useAccount();
const [username, setUsername] = useState<string>('');
const debouncedUsername = useDebounce(username, 500);
const { isSubnameAvailable } = useIsSubnameAvailable({
username: debouncedUsername
});
const { addSubname } = useAddSubname();
return (
<div>
<h1>Claim your subdomain</h1>
<ConnectButton />
<input
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Enter a subdomain"
/>
<button
onClick={() => addSubname({ username })}
disabled={!isSubnameAvailable || !isConnected || !debouncedUsername}
>
Claim
</button>
</div>
);
};
The SDK offers various hooks for managing ENS accounts, subnames, and authentication.
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.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.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.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.Contributions are welcome! If you have suggestions or find issues, please open an issue or submit a pull request on the GitHub repository.
FAQs
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 ensuri
We found that @justaname.id/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.