This file provides guidance to Codex (openai.com/codex) when working with code in this repository.
RainbowKit is a pnpm monorepo containing multiple packages:
packages/rainbowkit- Core library: React components and hooks for wallet connection UIpackages/rainbow-button- Standalone rainbow button componentpackages/rainbowkit-siwe-next-auth- Sign-In with Ethereum integration with NextAuth.jspackages/create-rainbowkit- CLI tool for scaffolding new RainbowKit projectspackages/example- Development example app (runs on localhost:3000)site- Documentation site (runs on localhost:3001)examples/- Additional example integrations (Next.js, Vite, Remix, etc.)
pnpm install # Install dependencies and generate type definitions from rootpnpm dev # Run example app + site (localhost:3000 and :3001)
pnpm dev:lib # Watch and rebuild library packages only
pnpm dev:example # Run lib + example app only
pnpm dev:site # Run lib + docs site only
pnpm dev:cli # Watch mode for create-rainbowkit CLI
pnpm dev:template:next-app # Run Next.js app template directlypnpm build # Build all packages (excludes template apps)pnpm test # Run all unit tests (uses Vitest)
pnpm test:unit run -t "<name>" # Run specific test by name
pnpm test:update # Update test snapshots
pnpm test:watch # Watch mode for tests
pnpm test:cli # Test CLI scaffolding (builds template)
pnpm test:cli:dev # Scaffold template + start dev server
pnpm test:cli:clean # Remove generated test apppnpm lint # Check formatting + typecheck all packages
pnpm lint:fix # Auto-fix formatting issues
pnpm format:check # Check Biome formatting only
pnpm format:fix # Auto-fix Biome formatting (run before commits)Built with:
- Styling: Vanilla Extract for type-safe CSS-in-JS with CSS modules
- Build: Custom esbuild setup (
build.js) with watch mode - Bundling: ESM format with code splitting for tree shaking
Key directories:
src/components/- UI components (ConnectButton, modals, etc.)src/wallets/- Wallet connector definitions and registrysrc/themes/- Theme system (light, dark, midnight)src/locales/- Internationalization filessrc/hooks/- React hooks for wallet interactionssrc/css/- Vanilla Extract styles
Build process:
- TypeScript type generation runs first (
typegen) - esbuild compiles main entry + wallets separately
- Vanilla Extract processes CSS with autoprefixer and selector prefixing (
[data-rk]) - SVGs are inlined as data URLs, PNGs as base64
Environment variables required (.env.local):
RAINBOW_PROVIDER_API_KEY- For enhanced provider featuresWALLETCONNECT_PROJECT_ID- For WalletConnect integration
- Framework: Vitest with jsdom environment
- Setup:
packages/rainbowkit/test/setup.ts - Config: Root
vitest.config.tswith Vanilla Extract plugin - Tests located alongside source files (
.test.ts/.test.tsx)
Follow conventional commits as defined in commitlint.config.js:
- Types:
fix,feat,test,tooling,refactor,revert,example,docs,format,chore - Example:
fix: resolve wallet disconnect issue
Always create a changeset for user-facing changes:
pnpm changeset # Creates markdown file in .changeset/- Prefer patch versions unless change warrants minor/major
- Never edit CHANGELOG.md files directly (auto-generated)
- Update existing changesets in same area rather than creating duplicates
- Patch bump
@rainbow-me/create-rainbowkitwhen template dependencies change
Use the following tools for git operations:
- Graphite (
gt) - Preferred tool for all git interactions:- Creating commits:
gt create -m "commit message" - Modifying existing commits:
gt modify- Prefer this over adding new commits unless explicitly asked
- Need to stage changes with git add or use --all to stage all changes
- Always resubmit after running gt modify using
gt submit --stack
- Creating branches:
gt branch create <branch-name> - Tracking branches:
gt track- Always track branches if they aren't already tracked - Moving branches in stack:
gt move --onto <target-branch>- Use when repositioning commits/branches - Submitting/updating pull requests:
gt submit --stack - Checking out PRs:
gt checkout <pr-number> - Resubmitting after changes: Always run
gt submit --stackafter making changes or commits - Always ask before committing changes or manipulating/resubmitting branches or opening PRs
- Always use gt modify by default when asked to make a commit
- Creating commits:
- GitHub CLI (
gh) - For viewing CI/CD status:- Use
gh run listto view workflow runs - Use
gh run viewto investigate specific CI failures
- Use
Only modify en-US.json locale files. Other language files are managed separately.
See .github/workflows/ci.yml for full test plan:
- Install dependencies
- Build all packages
- Run linting and formatting checks
- Run unit tests (
pnpm test) - Run CLI tests (
pnpm test:cli)
All checks must pass before merging.
Template location: packages/create-rainbowkit/templates/next-app/
After template changes:
pnpm test:cli:dev # Scaffold and test template (updates lockfile)Commit the generated lockfile to keep monorepo in sync.
Link CLI globally for testing:
pnpm link:cli # Makes `create-rainbowkit` available system-wide- Uses Biome for formatting/linting (replaces ESLint + Prettier)
- React 19 and Next.js 15 compatible
- Built on wagmi v2 and viem 2.x
- Node.js >= 20 required