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

@carlesandres/component-identity

v0.1.1

Published

Audit exported React components for canonical data-component root attributes.

Readme

@carlesandres/component-identity

Audit exported React components for a canonical data-component root attribute.

The convention is intentionally strict:

export function UserMenu() {
  return <div data-component="user-menu" />;
}

UserMenu maps to data-component="user-menu". The mapping is one-to-one and uses kebab-case derived from the component name.

Install

npm install --save-dev @carlesandres/component-identity

Use

After installing the package, add a config file:

npx component-identity init
npx component-identity init --preset next

Run the audit:

npx component-identity audit

Use JSON output for CI, reports, or agent tooling:

npx component-identity report
npx component-identity audit --json

For one-off use without installing first, use the scoped package name:

npx @carlesandres/component-identity audit

The audit exits with code 1 when violations are found, so it can be used directly in CI.

{
  "scripts": {
    "audit:components": "component-identity audit"
  }
}

What It Checks

The MVP checks named exported React components that return a root host DOM element:

export function UserMenu() {
  return <div data-component="user-menu" />;
}

export const AccountCard = () => {
  return <section data-component="account-card" />;
};

It supports exported components declared as:

  • export function ComponentName() { ... }
  • export const ComponentName = () => ...
  • export default function ComponentName() { ... }
  • const ComponentName = () => ...; export default ComponentName
  • const ComponentName = () => ...; export { ComponentName }
  • memo(ComponentName) and nested forwardRef(memo(...)) wrappers
export const Button = forwardRef<HTMLButtonElement>((props, ref) => {
  return <button ref={ref} data-component="button" {...props} />;
});

Fragments are audited through their first meaningful JSX DOM child. Empty fragments are reported as skipped with a fragment-root reason.

It ignores private components and reports skipped exported components whose root is another custom component or a non-JSX expression such as a portal call. Custom component roots can be treated as pass-through wrappers with passThroughComponents.

Autofix

Simple missing or mismatched static root attributes can be fixed in place:

npx component-identity audit --fix

Config

component-identity.config.json:

{
  "attribute": "data-component",
  "include": [
    "src/**/*.{ts,tsx,js,jsx}",
    "app/**/*.{ts,tsx,js,jsx}",
    "components/**/*.{ts,tsx,js,jsx}"
  ],
  "exclude": [
    "**/components/ui/**",
    "**/*.test.*",
    "**/*.spec.*",
    "**/*.stories.*",
    "**/*.d.ts",
    "**/node_modules/**",
    "**/dist/**"
  ],
  "excludeFiles": [],
  "excludeComponents": [],
  "passThroughComponents": []
}

Use --config to point at another config file and --cwd to audit a different directory. excludeFiles is an alias for additional file globs; excludeComponents accepts exact component names or * wildcards.

Use "preset": "next", npx component-identity init --preset next, or the exported nextConfig for Next.js projects. It extends the default excludes with app/page entry files such as pages, layouts, loading, error, and not-found files, while keeping tests, stories, and components/ui excluded.

JSON reports include coverage fields: componentsFound, componentsChecked, components, auditedComponents, skippedComponents, fixesApplied, and violations.

Library API

import { audit, componentNameToKebabCase } from "@carlesandres/component-identity";

const result = audit({ cwd: process.cwd() });

if (!result.ok) {
  console.log(result.violations);
}

console.log(componentNameToKebabCase("UserMenu")); // "user-menu"

Versioning And Publishing

This package is designed for normal npm versioning:

npm run check
npm test
npm run pack:dry
npm run version:patch
npm run publish:public

npm run prepack builds dist/ before packaging.

Contributions

This project is in a very early stage. For now, issues are accepted as contributions, but pull requests are not.