A Next.js starter kit demonstrating the integration of Namespace Offchain Manager SDK with RainbowKit for creating and managing Offchain ENS subnames.
- Rainbow Kit UI with Offchain subname creation / fetch logic.
- You get reverse resolution for address for offchain subnames. [0x23...] -> happy.offchainsub.eth
π Repository: https://github.com/thenamespace/offchain-next-rainbowkit-template
- Node.js (v18 or later)
- An ENS name (e.g.,
offchainsub.eth) - Namespace API key from the Dev Portal
git clone https://github.com/thenamespace/offchain-next-rainbowkit-template.git
cd offchain-next-rainbowkit-template
npm installCreate a .env.local file in the root directory:
# Your ENS name (eg. offchainsub.eth)
NEXT_PUBLIC_ENS_NAME=yourname
# Your Namespace API key (keep this secret!)
NAMESPACE_API_KEY=your_api_key_here- 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
npm run devOpen http://localhost:3000 to see the application.
This starter kit provides a complete implementation with:
- Custom connect button with Namespace subname support
- Account modal with subname creation functionality
- Automatic primary name resolution
- 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
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
POST /api/subname/create- Create subnames with custom address and text records
- Custom Ethereum addresses
- Avatar/PFP support via text records
- Display name customization
- Metadata tracking (sender address)
A replacement for RainbowKit's default ConnectButton that:
- Shows subnames instead of truncated addresses
- Displays custom avatars from subname text records
- Provides seamless wallet connection experience
A comprehensive account management interface that:
- Shows current subname and balance
- Allows creation of new subnames
- Validates subname availability in real-time
- Supports custom avatars and display names
- 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
- 2,000 subnames can be created per API key to prevent abuse
- Need more? Contact us on Builders Group
src/
βββ app/
β βββ api/subname/create/route.ts # Server-side subname creation
β βββ page.tsx # Main demo page
β βββ providers.tsx # RainbowKit & Wagmi setup
βββ components/
β βββ kit/
β βββ AccountModal.tsx # Account management modal
β βββ CustomConnectButton.tsx # Custom connect button
βββ hooks/
β βββ use-subnames.ts # Subname fetching hooks
β βββ use-subname-creation.ts # Subname creation hooks
βββ lib/
βββ namespace.ts # Server-side client (with API key)
βββ namespace-client.ts # Client-side client (read-only)
- GitHub Repository: https://github.com/thenamespace/offchain-next-rainbowkit-template
- Documentation: https://docs.namespace.ninja/
- SDK Reference: Offchain Manager SDK
- Builders Group: https://t.me/+5FAwyiKOTeswNTIy
- RainbowKit Docs: https://rainbowkit.com/docs/introduction
This is a starter kit template. Feel free to customize and extend it for your specific use case. For questions or support, join our Builders Group on Telegram.
This project is open source and available under the MIT License.