shadcn releases 'cn' to speed up Tailwind class merging by 30x

shadcn releases 'cn' to speed up Tailwind class merging by 30x

cn drops into your Tailwind stack, replaces clsx and tailwind-merge, and runs 30 times faster with zero API changes.

Developers shadcn and aidenybai released cn, a zero-dependency engine for merging Tailwind classes and resolving conflicts. It provides exact parity with tailwind-merge and clsx across 356,000 differential tests, but optimizes execution to skip redundant string work. It works with any framework and any Tailwind CSS v4 project—no shadcn/ui components required.

Why it matters: For standard component calls, cn handles class merging in 10 nanoseconds compared to 320 nanoseconds with traditional setups. Benchmarks replaying calls across 58 open-source repositories show cn runs 37× faster on average while shipping a small 26 KB minified bundle. That means faster client renders and lighter edge execution without rewriting your existing components.

To switch, run npx shadcn@latest migrate cn or install it directly with npm i cn. In existing projects, update your @/lib/utils file to export { cn } from "cn" and remove clsx and tailwind-merge from your package dependencies.

Your component syntax stays identical, but your render loop just got a massive speed boost.

Sources