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

vite-tagger

v1.0.7

Published

A Vite plugin that automatically adds debug attributes to JSX elements for development

Readme

vite-tagger

🚀 Features

  • Automatic Debug Attributes: Adds data-vt-id, data-vt-name and other debug attributes to JSX elements
  • 🎯 Element Tracing: Includes file path, line number, and column information for easy element location
  • 🔍 DevTools Friendly: Enhances browser developer tools debugging experience
  • 🎨 3D Framework Support: Intelligently filters Three.js and Drei elements
  • Development Mode Only: Runs only in development mode by default
  • 🛠️ Highly Configurable: Custom prefixes, include/exclude patterns, and more
  • 🎛️ Customizable Attributes: Control which debug attributes are added to elements
  • 📦 Zero Runtime: Does not affect production builds
  • 🌏 TypeScript Support: Full TypeScript support and type definitions

📦 Installation

npm install vite-tagger --save-dev
# or
yarn add vite-tagger --dev
# or
pnpm add vite-tagger --save-dev

🔧 Usage

Basic Setup

Add the plugin to your vite.config.ts:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteTagger } from "vite-tagger";

export default defineConfig({
  plugins: [react(), viteTagger()],
});

Advanced Configuration

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteTagger } from "vite-tagger";

export default defineConfig({
  plugins: [
    react(),
    viteTagger({
      // Custom debug attribute prefix
      prefixName: "my-debug",
      // Enable debug logging
      debug: true,
      // Include additional file extensions
      include: [".tsx", ".jsx", ".mdx"],
      // Exclude specific paths
      exclude: ["node_modules", "dist", "build"],
      // Use absolute paths
      useRelativePath: false,
      // Disable 3D element filtering
      filter3DElements: false,
      // Force enable in production (not recommended)
      enabled: true,
      // Custom attributes to include
      attributesToInclude: ["id", "name", "line"],
    }),
  ],
});

🎯 How It Works

Before

function App() {
  return (
    <div className='container'>
      <h1>Hello World</h1>
      <button onClick={handleClick}>Click me</button>
    </div>
  );
}

After (in development)

function App() {
  return (
    <div
      className='container'
      data-vt-id='src/App.tsx:3:4'
      data-vt-name='div'
      data-component-path='src/App.tsx'
      data-component-line='3'
      data-component-file='App.tsx'
      data-component-name='div'
      data-component-content='%7B%22className%22%3A%22container%22%7D'
    >
      <h1
        data-vt-id='src/App.tsx:4:6'
        data-vt-name='h1'
        data-component-path='src/App.tsx'
        data-component-line='4'
        data-component-file='App.tsx'
        data-component-name='h1'
        data-component-content='%7B%22text%22%3A%22Hello%20World%22%7D'
      >
        Hello World
      </h1>
      <button
        onClick={handleClick}
        data-vt-id='src/App.tsx:5:6'
        data-vt-name='button'
        data-component-path='src/App.tsx'
        data-component-line='5'
        data-component-file='App.tsx'
        data-component-name='button'
        data-component-content='%7B%22text%22%3A%22Click%20me%22%7D'
      >
        Click me
      </button>
    </div>
  );
}

⚙️ Configuration Options

| Option | Type | Default | Description | | --------------------- | ---------- | --------------------------------------------------- | ------------------------------------- | | enabled | boolean | NODE_ENV === 'development' | Whether to enable the plugin | | prefixName | string | 'vt' | Custom prefix for debug attributes | | include | string[] | ['.tsx', '.jsx'] | File extensions to process | | exclude | string[] | ['node_modules'] | Paths to exclude | | useRelativePath | boolean | true | Use relative paths in debug info | | debug | boolean | false | Enable debug logging | | filter3DElements | boolean | true | Filter out Three.js/Drei elements | | attributesToInclude | string[] | ['id', 'name', 'path', 'line', 'file', 'content'] | Attributes to include in debug output |

🎨 Debug Attributes Explained

The plugin adds these debug attributes to help with development:

Primary Attributes

  • data-{prefix}-id: Unique identifier with path and position (path:line:col)
  • data-{prefix}-name: Element tag name

Legacy Attributes (for compatibility)

  • data-component-path: File path
  • data-component-line: Line number
  • data-component-file: File name
  • data-component-name: Element name
  • data-component-content: Encoded element content (text, class names, placeholders)

Note: data-component-content is only added when there's actual content to display.

Customizing Attributes

You can control which attributes are included using the attributesToInclude option:

viteTagger({
  // Only include ID and name attributes
  attributesToInclude: ["id", "name"],
});

Available attribute keys:

  • 'id': Adds data-{prefix}-id attribute
  • 'name': Adds data-{prefix}-name and data-component-name attributes
  • 'path': Adds data-component-path attribute
  • 'line': Adds data-component-line attribute
  • 'file': Adds data-component-file attribute
  • 'content': Adds data-component-content attribute (when content exists)

By default, all attributes are included.

🌍 Framework Support

Works with any Vite project using JSX:

  • ⚛️ React - Fully supported
  • Preact - Fully supported
  • 🔥 SolidJS - Fully supported
  • 📝 MDX - Add .mdx to the include option

🎯 Three.js & Drei Support

The plugin intelligently filters Three.js and Drei 3D elements by default, avoiding adding unnecessary debug attributes in 3D scenes. This feature can be disabled with filter3DElements: false.

🔍 Practical Usage Examples

1. Quick Element Lookup in Console

// Find all elements from a specific component
document.querySelectorAll('[data-vt-id*="Header.jsx"]');

// Find a specific element by line number
document.querySelector('[data-vt-id*=":42:"]');

2. CSS Debugging

/* Style all buttons from a specific file */
[data-vt-id*="ButtonGroup.jsx"] button {
  border: 2px solid red !important;
}

/* Highlight a specific problematic element */
[data-vt-id="src/components/Form.jsx:156:3"] {
  outline: 3px dashed orange !important;
}

3. Integration with Testing

// In your testing framework
test("header navigation renders correctly", () => {
  // Find elements by their component path
  const navLinks = screen.getAllByTestId(
    (id) => id.startsWith("data-vt-id") && id.includes("Navigation.jsx")
  );
  expect(navLinks.length).toBe(5);
});

4. Browser DevTools Filtering

  1. Open DevTools Elements panel
  2. Use the search function (Ctrl+F/Cmd+F)
  3. Search for data-vt-id*="ComponentName" to quickly locate elements from specific components

📝 License

MIT © kcsx