
cnfast
Fast drop in replacement for `cn`
The Lens
cnfast does the same job as the `cn` helper in every shadcn/ui project: it merges Tailwind class names so the right utility wins when two conflict (the thing that lets `p-2` and `p-4` resolve cleanly instead of fighting). It rolls clsx and tailwind-merge into one package and runs them faster, around 3.8x on average and up to 7x in component-heavy code, with byte-identical output. MIT-licensed, free, on npm.
Nothing to operate. It's a dependency. The speed comes from caching and a tagged-template syntax, and since the output matches tailwind-merge exactly, swapping it in is a find-and-replace on your import. There's a shadcn registry entry if you want it dropped straight into an existing project.
Solo: install it if className merging shows up in your render profiles, otherwise the default cn is fine. Small teams: low-risk swap, do it once and forget it. Large teams: the per-call savings add up across thousands of components, and the zero-breaking-change promise makes it an easy approval.
The catch: this solves a problem most apps don't have. className merge time is rarely your bottleneck, and adding a dependency to shave microseconds off something you never measured is premature optimization. Profile first. If clsx plus tailwind-merge isn't showing up, you don't need this.
Free vs Self-Hosted vs Paid
fully freeFree
The entire package. cnfast is MIT-licensed and published to npm. You get cn, clsx, twMerge, and twJoin exports, plus a shadcn/ui registry install. Byte-identical output to the tools it replaces.
Self-hosted
Not applicable. It's an npm dependency you bundle into your app.
Paid
None.
Free, MIT-licensed, and a one-command swap for the cn helper you already use.
Get tools like this every Wednesday
One featured tool, three on the radar. No fluff.
License: Other
Review license manually.
Commercial use: ✗ Restricted
About
- Owner
- Aiden Bai (User)
- Stars
- 1,030
- Forks
- 10