Skip to content
← Journal
2 min read

How We Built a Shadcn-Compatible Component Registry in Next.js App Router

Architecting a zero-vendor-lockin UI distribution engine with static edge registry JSON endpoints, CLI tooling, and automatic code transformation.


Traditional frontend component libraries rely heavily on npm package distribution. While convenient, this model binds applications to rigid version matrices, creates transitive dependency vulnerabilities, and prevents engineers from tailoring component internals to their specific design tokens.

When building the iFlevox UI ecosystem, we chose a fundamentally different architecture: a copy-paste component registry compatible with both the official shadcn CLI and our dedicated iflevox-ui command line tool.

Why developers hate component vendor lock-in

Shipping UI components as compiled npm binaries creates serious long-term maintenance friction for engineering organizations:

  • Inflexible styles require hacky CSS overrides and fragile specificity battles to adapt to company brand palettes.
  • Outdated peer dependencies block upgrades to the latest React major versions and Next.js compiler improvements.
  • Heavy bundled dependencies increase the overall JavaScript payload delivered across mobile network connections.
  • Closed component internals make it impossible for engineering teams to audit and enforce enterprise security controls.

Next.js App Router as a headless registry engine

To deliver code directly to developers, we built our registry upon the Next.js App Router using route handlers. The schema mirrors the open shadcn registry specification, serving self-describing JSON blueprints.

Every component route exposes metadata detailing required npm dependencies, Tailwind CSS plugins, internal utility functions, and raw TypeScript source files. Because these endpoints are statically cached at the edge, responses resolve with near-zero latency.

Automated AST code sanitization and token stripping

A component designed within the iFlevox design system utilizes specific CSS variables and custom utility wrappers. Directly pasting that code into an external repository would cause missing token errors. Our registry solves this through real-time code transformations:

  • Custom design tokens are systematically remapped to standard Tailwind CSS color palettes.
  • Internal import aliases are dynamically rewritten to match the target project directory structure.
  • Redundant demo wrappers and testing harnesses are cleanly stripped out of the delivered payload.
  • TypeScript interfaces and JSDoc annotations are preserved in their entirety to maintain developer ergonomics.

One-command installation with the iFlevox CLI

To provide a flawless installation experience, we built the iflevox-ui CLI. With a single command, developers can inspect, download, and configure components in their local projects:

  • Automatic package manager detection supports npm, pnpm, bun, and yarn without manual flags.
  • Intelligent dependency reconciliation audits existing packages and installs only missing peer dependencies.
  • Non-destructive write operations prompt developers before overwriting customized local component files.
  • Built-in token initialization scaffolds standard cn utility helpers and configuration manifests.

By publishing the component registry openly on the web, any developer can inspect and run our components without creating an account or paying subscription fees.

Written by Ozodbek Nazarov

Contact

Have something worth building?

Let’s turn an idea into something real.