cnfast
v0.2.0
Published
Fast drop-in replacement for `cn`
Maintainers
Readme
cnfast
Fast drop-in replacement for cn.
cnfast runs 25× faster than clsx + tailwind-merge across 58 real-world component repositories, with byte-identical output. Same API, no code changes.
import { cn } from "cnfast";
cn("px-2 py-1", isActive && "px-4", { "text-red-500": hasError });
// "py-1 px-4 text-red-500"Install
npm install cnfastMigrate an existing clsx, classnames, or tailwind-merge project in one command:
npx cnfast migrateOn a shadcn/ui project, add or replace your cn utility through the registry. This rewrites lib/utils.ts to re-export cnfast and installs the package:
npx shadcn@latest add aidenybai/cnfast/cnUsage
Swap the shadcn/ui cn helper for cnfast:
// before
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));
// after
export { cn } from "cnfast";cnfast also exports clsx, twMerge, and twJoin.
Development
ni
nr build
nr testLicense
MIT
