Skip to content

Repository files navigation

Namespace

ENS Components

Drop-in React components for ENS name registration, record editing, and subname issuance.

npmlicense

ENS UI Components for any React app


Live demo

enscomponents.com — interactive playground for all components with live prop editing and generated code snippets.


What's included

ComponentWhat it does
EnsNameRegistrationFormFull .eth registration flow — search, commit, wait, register
EnsRecordsFormEdit resolver records (addresses, text, contenthash, avatar) for a name you own
SelectRecordsFormStandalone record composer — no wallet or transaction required
SubnameMintFormMint onchain subnames from a Namespace listing
OffchainSubnameFormCreate and update gasless offchain subnames via the Namespace API

EnsRecordsForm, SubnameMintForm, and OffchainSubnameForm accept both native .eth names and DNS names that have been imported into ENS, such as example.com. The relevant Namespace listing or API key must already be configured for the parent name. EnsNameRegistrationForm remains .eth-only because it uses the ENS ETH Registrar Controller; import DNS names into ENS before passing them to the other components.


Install

npm install @thenamespace/ens-components
# or
pnpm add @thenamespace/ens-components

Install peer dependencies if you don't have them already:

npm install react react-dom wagmi viem @tanstack/react-query

Setup

1. Add styles

import"@thenamespace/ens-components/styles.css";

2. Wrap your app with wagmi providers

The components require WagmiProvider and QueryClientProvider. The example below uses RainbowKit for wallet connection — any wagmi-compatible setup works.

import"@rainbow-me/rainbowkit/styles.css";import{getDefaultConfig,RainbowKitProvider}from"@rainbow-me/rainbowkit";import{WagmiProvider}from"wagmi";import{mainnet,sepolia}from"wagmi/chains";import{QueryClientProvider,QueryClient}from"@tanstack/react-query";constconfig=getDefaultConfig({appName: "My App",projectId: "YOUR_WALLETCONNECT_PROJECT_ID",chains: [mainnet,sepolia],});exportfunctionProviders({ children }: {children: React.ReactNode}){return(<WagmiProviderconfig={config}><QueryClientProviderclient={newQueryClient()}><RainbowKitProvider>{children}</RainbowKitProvider></QueryClientProvider></WagmiProvider>);}

Components

EnsNameRegistrationForm

Guides users through the full .eth registration flow: search → commit → wait → register.

import{EnsNameRegistrationForm}from"@thenamespace/ens-components";<EnsNameRegistrationFormisTestnet={false}referrer="0xYourReferrerAddress"onConnectWallet={()=>openConnectModal()}/>
PropTypeDescription
isTestnetbooleanUse Sepolia instead of mainnet
referrerstringRegistration referrer wallet address
noBorderbooleanRemove the card border
titlestringOverride the form heading
subtitlestringOverride the subtitle
bannerImagestringCustom banner image URL
hideBannerbooleanHide the banner entirely
onConnectWallet() => voidCalled when the user needs to connect a wallet

EnsRecordsForm

Edit all resolver records for an ENS name the connected wallet owns.

import{EnsRecordsForm}from"@thenamespace/ens-components";<EnsRecordsFormname="alice.eth"existingRecords={{addresses: [],texts: []}}isTestnet={false}/>
PropTypeDescription
namestringENS name to edit (.eth or a DNS name imported into ENS)
existingRecordsEnsRecordsCurrent on-chain records
isTestnetbooleanUse Sepolia instead of mainnet
noBorderbooleanRemove the card border
txConfirmationsnumberBlock confirmations to wait after tx
onCancel() => voidCalled when the user cancels

SelectRecordsForm

Standalone record editor with no wallet or transaction required. Use it to compose records before passing them to any other form.

import{SelectRecordsForm}from"@thenamespace/ens-components";import{useState}from"react";const[records,setRecords]=useState({addresses: [],texts: []});<SelectRecordsFormrecords={records}onRecordsUpdated={setRecords}/>

SubnameMintForm

Full minting flow for onchain subnames — price lookup, profile records, and the mint transaction.

import{SubnameMintForm}from"@thenamespace/ens-components";<SubnameMintFormparentName="yourname.eth"isTestnet={false}onConnectWallet={()=>openConnectModal()}/>
PropTypeDescription
parentNamestringENS parent (.eth or ENS-imported DNS) with an active Namespace listing
isTestnetbooleanUse Sepolia instead of mainnet
txConfirmationsnumberBlock confirmations to wait after tx
onConnectWallet() => voidCalled when the user needs to connect
onCancel() => voidCalled when the user cancels

OffchainSubnameForm

Create and update gasless offchain subnames through the Namespace API. Requires an API key from dev.namespace.ninja.

import{OffchainSubnameForm}from"@thenamespace/ens-components";import{createOffchainClient}from"@thenamespace/offchain-manager";constoffchainManager=createOffchainClient({domainApiKeys: {"yourname.eth": "your-api-key"},mode: "mainnet",// or "sepolia"});<OffchainSubnameFormname="yourname.eth"offchainManager={offchainManager}onSubnameCreated={async(data)=>{awaitoffchainManager.createSubname(data);}}onSubnameUpdated={async(data)=>{awaitoffchainManager.updateSubname(data.fullSubname,data);}}/>

Install the offchain manager separately:

npm install @thenamespace/offchain-manager
PropTypeDescription
namestringParent ENS name (.eth or ENS-imported DNS)
offchainManagerOffchainClientClient from createOffchainClient()
isTestnetbooleanUse Sepolia instead of mainnet
labelstringPre-fill and lock the subname label
titlestringOverride the header title
subtitlestringShow a subtitle below the header
hideTitlebooleanHide the header entirely
onSubnameCreated(data) => Promise<void>Called after a new subname is submitted
onSubnameUpdated(data) => Promise<void>Called after an existing subname is updated

Theming

All colors, radii, and spacing are CSS variables. Override them in your own stylesheet to match your brand:

:root {
--ns-color-primary:#3b82f6;
--ns-color-bg:#ffffff;
--ns-color-bg-secondary:#f9fafb;
--ns-color-text:#111827;
--ns-color-text-secondary:#6b7280;
--ns-color-border:#e5e7eb;
--ns-radius-md:8px;
--ns-radius-lg:12px;
}

Repository structure

ui-components/
├── packages/
│ └── components/ # @thenamespace/ens-components (published to npm)
└── apps/
├── storybook/ # Storybook 8 component explorer (port 6006)
└── landing/ # Interactive demo & docs (port 4000)

Local development

# Install all workspace dependencies
pnpm install
# Start the landing page (http://localhost:4000)
pnpm --filter landing dev
# Start Storybook (http://localhost:6006)
pnpm --filter storybook dev
# Build the library
pnpm --filter @thenamespace/ens-components build
# Build everything in dependency order
turbo run build

Links

About

Drop-in React components for ENS name registration, record editing, and subname issuance.

Topics

Resources

Code of conduct

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages