npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cnfast

v0.0.8

Published

Fast drop-in replacement for `cn`

Readme

cnfast

version downloads

Fast drop-in replacement for cn.

cnfast runs 3.2x faster on average than clsx + tailwind-merge, up to 7x with tagged templates, 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 cnfast

Migrate an existing clsx, classnames, or tailwind-merge project in one command:

npx cnfast migrate

On 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/cn

Usage

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.

Going even faster

As a tagged template, cn caches by call-site identity: a stable call site runs 2.6x faster than the cn(...) call form and 7x faster than clsx + tailwind-merge.

cn`px-2 px-4 ${isActive && "bg-blue-500"}`; // "px-4 bg-blue-500"

Comparing against cn

cnfast produces byte-identical output to clsx + tailwind-merge, then does that work faster. On a re-rendering call site, the tagged-template form pulls furthest ahead:

cnfast on a re-rendering call site, operations per second

Across the wider suite, operations per second on Bun, best-of-3:

| Workload | clsx + tailwind-merge | cnfast | Speedup | | ------------------ | --------------------- | ----------- | --------- | | Cached re-render | 2,192 ops/s | 2,925 ops/s | 1.33x | | Merge engine, cold | 473 ops/s | 2,153 ops/s | 4.55x | | Component corpus | 682 ops/s | 2,421 ops/s | 3.55x | | Page render | 3,047 ops/s | 5,614 ops/s | 1.84x | | Live data grid | 128 ops/s | 231 ops/s | 1.81x |

Corpus and page rows are geometric means across 53 Tailwind apps and 8 captured pages; cached/cold/grid rows are single workloads. Across 65 workloads the geometric mean is 3.17x, with 0 mismatches over 113,291 real-world call groups. The bundle is 9.04 KB gzipped against 8.45 KB for the baseline.

cn runs once per element, so its cost scales with how much you render. Server-rendering a large page calls it across the whole tree, and a client app that re-renders often (data grids, virtualized tables, live dashboards) calls it thousands of times per second. A faster cn keeps those busy frames inside budget. On a small or rarely-updated page, the saving disappears into noise.

See the benchmark suite for the full breakdown and the architecture guide for how it works.

Credits

cnfast adapts MIT-licensed code from clsx (Luke Edwards) and tailwind-merge (Dany Castillo). See LICENSE.

License

MIT