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

klsx

v0.3.3

Published

Same as clsx but "maybe" better

Readme

🎨 𝒌𝒍𝒔𝒙

A simple replacement for clsx you may not actually need (see the benchmark)

Used to construct class conditionally with strings, arrays and key-value objects.

Developed as a case study, Bun friendly. 🌿

Features

  • 🚀 Unnecessarily fast (~20M ops/s)
  • 🎯 Same functionality and API of clsx
  • 👑 Modern ESM syntax
  • 💎 Zero dependencies
  • ☀️ No "lite" mode (simply doesn't make any sense)
  • 🎈 Only 277B (~190B compressed)
  • 🐳 Deeply typed and tested
  • 🚨 Experimental WASM variant (for research purposes, do not use it)

Installation

bun add klsx

or with npm:

npm install klsx

Quick Start

import { klsx } from 'klsx'

klsx('foo', 'bar', 'baz')
// => "foo bar baz"

klsx({ foo: 'string', bar: true, bux: null }, 'baz')
// => "foo bar baz"

klsx(['foo', ['bar', true && 'baz']])
// => "foo bar baz"

or importing the short alias kx:

React

import React, { useState } from 'react'
import { kx } from 'klsx'

const MyComponent = () => {
  const [isActive, setIsActive] = useState(false)
  return (
    <div>
      <div className={kx('base-class', isActive ? 'active' : 'inactive')}>
        {/* ... */}
      </div>

      <div className={kx('base-class', { active: isActive, inactive: !isActive })}>
        {/* ... */}
      </div>

      <div
        className={kx('base-class', [isActive && 'active', !isActive && 'inactive'])}
      >
        {/* ... */}
      </div>
    </div>
  )
}

Migrate from clsx

Just replace every c with a k, as in the example below.

From:

// clsx

import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

To:

// KLSX

import { klsx, type KlassValue } from 'klsx'
import { twMerge } from 'tailwind-merge'

export function cn(...inputs: KlassValue[]) {
  return twMerge(klsx(inputs))
}

Integrations

Tailwind CSS

Visual Studio Code

  1. Install the Tailwind CSS IntelliSense extension:
code --install-extension bradlc.vscode-tailwindcss
  1. Update your settings.json configuration with:
{
  "tailwindCSS.classFunctions": ["klsx", "kx"]
}

Prettier

  1. Install the prettier-plugin-tailwindcss plugin:
bun add -D prettier prettier-plugin-tailwindcss
  1. Update your prettier.config.js configuration to handle klsx:
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
export default {
  plugins: ['prettier-plugin-tailwindcss'],
  tailwindFunctions: ['klsx', 'kx'],
}

ESLint

  1. Install the eslint-plugin-clsx plugin:
bun add -D eslint eslint-plugin-clsx
  1. Update your eslint.config.js configuration to handle klsx:
import { defineConfig } from 'eslint/config'
import clsx from 'eslint-plugin-clsx'

export default defineConfig({
  plugins: { clsx },
  settings: {
    clsxOptions: {
      klsx: ['default', 'klsx', 'kx'],
    },
  },
})

Development

Install dependencies:

bun install

Build dist files:

bun run build

Testing

Run test suite:

bun test

Run benchmark suite:

bun bench