This document details the core packages within the shadcn/ui monorepo, focusing on the CLI package shadcn, the React primitives package @shadcn/react, the AI SDK utilities package @shadcn/helpers, and the tests package which provides test infrastructure.
The monorepo hosts the following primary core packages under the packages/ directory:
| Package | Location | Purpose | Published |
|---|---|---|---|
shadcn | packages/shadcn/ | Main CLI tool and programmatic API for the system | Yes (npm) |
@shadcn/react | packages/react/ | Headless unstyled React primitives (e.g., Chat UI) | Yes (npm) |
@shadcn/helpers | packages/helpers/ | AI SDK and TanStack AI utilities for chat testing | Yes (npm) |
tests | packages/tests/ | Integration test infrastructure for CLI commands | No |
Sources: packages/shadcn/package.json1-33 packages/react/package.json1-74 packages/helpers/package.json1-80 packages/tests/package.json1-26
The shadcn package is the core command-line interface (CLI) tool. It manages component installation, project configuration, registry interaction, and code transformation.
dist/index.js packages/shadcn/package.json64tsup to compile multiple entry points including the main CLI, registry API, schema definitions, MCP server, and presets packages/shadcn/package.json68-70tailwind.css artifact to the dist/ directory packages/shadcn/package.json18-19Sources: packages/shadcn/package.json30-64
commander for command routing packages/shadcn/package.json96init, add, apply, search, view, docs, info, build, registry, eject, migrate, and preset.shadcn mcp packages/shadcn/package.json85This module handles interaction with remote and local component registries. It provides functions to fetch the registry index, list items, and resolve dependencies across registries. It implements custom error handling for scenarios like RegistryNotFoundError and RegistryUnauthorizedError.
Sources: packages/shadcn/src/registry/index.ts1-32 packages/shadcn/src/registry/errors.ts5-28
The @shadcn/react package provides unstyled, accessible, headless UI primitives used internally across components, particularly in the chat and AI-driven UI systems.
asChild pattern).Sources: packages/react/package.json36-41 packages/react/CHANGELOG.md7-11
The @shadcn/helpers package provides utilities for developing and testing AI-driven applications. It specifically supports the Vercel AI SDK and TanStack AI.
./ai-sdk and ./tanstack-ai packages/helpers/package.json36-45Sources: packages/helpers/package.json1-80 packages/helpers/CHANGELOG.md7
The packages/tests package contains integration tests targeting the CLI commands to ensure stability across frameworks (Next.js, Vite, etc.).
vitest as the primary test runner packages/tests/package.json8msw to intercept HTTP requests and serve mock component data during CLI execution.vite-app, next-app) to test commands in realistic environments packages/tests/fixtures/vite-app/vite.config.ts1-15Sources: packages/tests/package.json1-26 packages/shadcn/package.json127
The following diagram illustrates how the core packages interact during a standard add command flow.
Sources: packages/shadcn/package.json30-64 packages/shadcn/src/registry/index.ts1-32
Core packages are managed via pnpm workspaces and published using changesets.
turbo run build triggers tsup in each package package.json16-17v4 application triggers a build of shadcn, @shadcn/react, and @shadcn/helpers before generating the registry files apps/v4/package.json18beta, rc, next) using scripts in packages/shadcn/package.json packages/shadcn/package.json79-82Sources: package.json16-17 apps/v4/package.json18 packages/shadcn/package.json79-82
Refresh this wiki
This wiki was recently refreshed. Please wait 2 days to refresh again.