This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Use
pnpm install(orpnpm install --ignore-scriptson Windows) - Monorepo managed with Turborepo and pnpm workspaces
# Build all packages
pnpm build
# Build specific packages with dependencies
turbo run build --filter=./packages/*
# Development with watch mode
pnpm dev # Core thirdweb package
pnpm dashboard # Run dashboard + dependencies
pnpm playground # Run playground + dependencies
pnpm portal # Run portal docs + dependencies# Run all tests
pnpm test
# Interactive testing (thirdweb package)
cd packages/thirdweb && pnpm test:devr
# Test specific file
pnpm test:dev <path-to-test-file>
# E2E testing (dashboard)
cd apps/dashboard && pnpm playwright# Lint all packages
pnpm lint
# Auto-fix linting issues
pnpm fix
# Format code
turbo run format
# Biome is the primary linter/formatter# Start development server for dashboard
pnpm dashboard
# Start playground for SDK testing
pnpm playground
# Generate changeset for releases
pnpm changeset
# Version packages
pnpm version-packagesThis is a Turborepo monorepo with the main thirdweb v5 SDK consolidated into /packages/thirdweb/. Legacy packages are in /legacy_packages/.
Main Modules:
client/- ThirdwebClient foundationchains/- 50+ supported blockchain definitionscontract/- Contract interaction with automatic ABI resolutiontransaction/- Transaction management and executionwallets/- Comprehensive wallet integration systemextensions/- Modular contract extensions (ERC20, ERC721, etc.)auth/- SIWE authentication and signature verificationpay/- Fiat and crypto payment infrastructurestorage/- IPFS integration for decentralized storagerpc/- Low-level blockchain communication
Exports Structure:
The SDK uses modular exports from src/exports/ including:
thirdweb.ts- Core client and utilitieschains.ts- Chain definitionswallets.ts- Wallet connectorsreact.ts- React hooks and componentsextensions/- Contract standards and protocols
- dashboard - Web-based developer console (Next.js, Chakra UI)
- playground-web - Interactive SDK testing environment
- portal - Documentation site with MDX
- nebula - Account abstraction and smart wallet management
- wallet-ui - Wallet interface and testing
- thirdweb - Main SDK (TypeScript, React, React Native)
- engine - thirdweb Engine API client
- insight - Analytics and data APIs
- nebula - Account abstraction client
- service-utils - Shared utilities across services
- PR titles: Must start with affected workspace in brackets (e.g.
[SDK],[Dashboard],[Portal],[Playground]) - PR descriptions: Begin with one-sentence summary, add checklist of changes, reference issues with
Fixes #123 - Commits: Keep small and topical – one logical change per commit
- Branch naming: Use
area/brief-topicformat (e.g.sdk/fix-gas-estimate). Avoid personal names - Reviews: Request at least one core maintainer review. Do not self-merge unless sole package owner
- CI requirements: All checks (type-check, Biome, tests) must pass before merging
- Biome: Primary linter/formatter (rules in
biome.json) - Pre-commit: Run
pnpm biome check --applybefore committing - Build verification: Run
pnpm buildafter each file change to ensure everything builds - Avoid editor-specific configs; rely on shared settings
- Style: Write idiomatic TypeScript with explicit function declarations and return types
- File structure: Limit each file to one stateless, single-responsibility function for clarity
- Types: Re-use shared types from
@/typesor localtypes.tsbarrels - Interfaces vs Types: Prefer type aliases over interface except for nominal shapes
- Type safety: Avoid
anyandunknownunless unavoidable; narrow generics when possible - Architecture: Choose composition over inheritance; leverage utility types (
Partial,Pick, etc.)
- Co-location: Place tests alongside code:
foo.ts↔foo.test.ts - Test approach: Use real function invocations with stub data; avoid brittle mocks
- Network mocking: Use Mock Service Worker (MSW) for fetch/HTTP call interception
- Test quality: Keep tests deterministic and side-effect free
- Running tests:
cd packages/thirdweb && pnpm test:dev <filename> - Test accounts: Predefined accounts in
test/src/test-wallets.ts - Chain forking: Use
FORKED_ETHEREUM_CHAINfor mainnet interactions,ANVIL_CHAINfor isolated tests
- Exports: Export everything via
exports/directory, grouped by feature - Documentation: Every public symbol must have comprehensive TSDoc with:
- At least one
@exampleblock that compiles - Custom annotation tags (
@beta,@internal,@experimental)
- At least one
- Comments: Comment only ambiguous logic; avoid restating TypeScript in prose
- Lazy loading: Load heavy dependencies inside async paths to keep initial bundle lean:
const { jsPDF } = await import("jspdf");
- Bundle budgets: Track via
package.json#size-limit - Dependencies: De-duplicate across packages through pnpm workspace hoisting
- Core components: Import primitives from
@/components/ui/*(Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) - Navigation: Use
NavLinkfor internal navigation with automatic active states - Organization: Group feature-specific components under
feature/components/*with barrelindex.ts
- CSS framework: Tailwind CSS only – no inline styles or CSS modules
- Class merging: Use
cn()from@/lib/utilsfor conditional logic - Design tokens: Use design system tokens (backgrounds:
bg-card, borders:border-border, muted text:text-muted-foreground) - Component API: Expose
classNameprop on root element for overrides
- Server Components (Node edge):
- Start files with
import "server-only"; - Read cookies/headers with
next/headers - Access server-only environment variables
- Perform heavy data fetching
- Implement redirect logic with
redirect()fromnext/navigation
- Start files with
- Client Components (browser):
- Begin files with
'use client'; - Handle interactive UI with React hooks (
useState,useEffect, React Query, wallet hooks) - Access browser APIs (
localStorage,window,IntersectionObserver) - Support fast transitions with prefetched data
- Begin files with
- Server Side:
- Always call
getAuthToken()to retrieve JWT from cookies - Use
Authorization: Bearerheader – never embed tokens in URLs - Return typed results (
Project[],User[]) – avoidany
- Always call
- Client Side:
- Wrap calls in React Query (
@tanstack/react-query) - Use descriptive, stable
queryKeysfor cache hits - Configure
staleTime/cacheTimebased on freshness (default ≥ 60s) - Keep tokens secret via internal API routes or server actions
- Wrap calls in React Query (
- When to add: Only create events that answer clear product/business questions
- Check duplicates: Review
src/@/analytics/report.tsfirst - Naming:
- Event name: human-readable
<subject> <verb>(e.g. "contract deployed") - Function:
report<Subject><Verb>(PascalCase)
- Event name: human-readable
- Template:
/** * ### Why do we need to report this event? * - Tracks number of contracts deployed * * ### Who is responsible for this event? * @username */ export function reportContractDeployed(properties: { address: string; chainId: number; }) { posthog.capture("contract deployed", properties); }
- Client-side only: Never import
posthog-jsin server components - Changes: Inform #eng-core-services before renaming/removing events
- Extensions follow modular pattern in
src/extensions/ - Auto-generated contracts from ABI definitions
- Composable functions with TypeScript safety
- Support for read/write operations
- Unified
WalletandAccountinterfaces - Support for in-app wallets (social/email login)
- Smart wallets with account abstraction
- EIP-1193, EIP-5792, EIP-7702 standard support
- Fork and Clone: Create fork, clone, create feature branch
- Install:
pnpm install(use--ignore-scriptson Windows) - Develop: Use appropriate dev commands above
- Test: Write unit tests, run linting, test on demo apps
- Changeset: Run
pnpm changesetfor semantic versioning - PR: Submit pull request to main branch
Comment /release-pr on PR to trigger dev release to npm for testing.
Each change in packages/* should contain a changeset for the appropriate package with the appropriate version bump:
- patch: Changes that don't impact the public API
- minor: Any new/modified public API
- major: Breaking changes (surface prominently in PR descriptions)
- For new UI components, add Storybook stories (
*.stories.tsx) alongside the code - Surface breaking changes prominently in PR descriptions
- Keep documentation focused on developer experience and practical usage
The SDK supports:
- Web: React hooks and components
- React Native: Mobile-specific exports and components
- Node.js: Server-side functionality
- Framework Adapters: Wagmi, Ethers compatibility layers
Key files:
src/exports/react.native.ts- React Native specific exportspackages/react-native-adapter/- Mobile platform shimspackages/wagmi-adapter/- Wagmi ecosystem integration