ENS Offchain Subnames + RainbowKit Starter Kit
A Next.js starter integrating the Offchain Manager SDK with RainbowKit for creating and managing offchain ENS subnames.Features
- RainbowKit UI with offchain subname creation and fetch logic
- Reverse resolution for addresses, e.g.,
0x23...βhappy.offchainsub.eth
thenamespace/ens-subnames-rainbowkit-template
Prerequisites
- Node.js (v18 or later)
- An ENS name (e.g.,
offchainsub.eth) - Namespace API key from the Dev Portal
Setup
1
Clone and install
2
Environment variables
Create a
.env.local file in the root directory:3
Configure your ENS name
- Visit the Namespace Dev Portal
- Change the resolver for your ENS name to Namespaceβs resolver
- Generate and copy your API key
- Add both to your
.env.localfile
4
Run the development server
http://localhost:3000 to see the application.5
It's ready!

Whatβs included
π RainbowKit Integration
- Custom connect button with Namespace subname support
- Account modal with subname creation functionality
- Automatic primary name resolution
File Structure
ποΈ Architecture
- Server-side Namespace client (
/src/lib/namespace.ts) - Uses API key securely for write operations - Client-side Namespace client (
/src/lib/namespace-client.ts) - For read-only operations without API key exposure - API route (
/src/app/api/subname/create/route.ts) - Server-side subname creation endpoint
πͺ Custom Hooks
useSubnames- Fetch subnames for an addressuseFirstSubname- Get the primary subname for an addressusePreferredIdentity- Intelligent name resolution (subname β ENS β truncated address)useCreateSubname- Create new subnames with validationuseSubnameAvailability- Check if a subname is available
π‘ API Endpoints
POST /api/subname/create- Create subnames with custom address and text records
Security & Limitations
β οΈ Important Security Notes
- Never expose your Namespace API key to the client side
- API key is only used in server-side code (
/src/lib/namespace.tsand API routes) - Client-side operations use the public client without API key
π Rate Limits
- Up to 2,000 subnames can be created per API key to prevent abuse
- Need more? Contact us on the Builders Group
References
- GitHub Repository:
thenamespace/ens-subnames-rainbowkit-template - SDK Reference: Offchain Manager SDK
- Builders Group:
Telegram - RainbowKit Docs:
Introduction

