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

@react-xray/core

v0.0.1

Published

`@react-xray/core` is the low-level package that powers the React XRay inspector widget. It gives you the `XRay` component, the plugin contract, and the hooks/utilities that official and custom plugins use.

Readme

@react-xray/core

@react-xray/core is the low-level package that powers the React XRay inspector widget. It gives you the XRay component, the plugin contract, and the hooks/utilities that official and custom plugins use.

Use this package when you want to:

  • Mount the inspector yourself
  • Choose exactly which plugins to enable
  • Build custom plugins against the public core API

If you want the batteries-included bundle with all official plugins pre-wired, use react-xray instead.

Installation

pnpm add --dev @react-xray/core

Peer requirements:

  • react >= 18
  • react-dom >= 18

Minimal usage

Change your dev script to export the project root e.g.:

-    "dev": "vite"
+    "dev": "VITE_ROOT=$(pwd) vite",

Then add it next to your app:

import { XRay } from '@react-xray/core'

import App from './App'

export function Root() {
  return (
    <>
      <App />
      <XRay root={import.meta.env.VITE_ROOT} />
    </>
  )
}

root must be the absolute path to the project being inspected.

When to use @react-xray/core vs react-xray

  • Use @react-xray/core when you want a custom plugin list or your own plugins.
  • Use react-xray when you want the default bundle of official plugins (preview, copy-to-clipboard, open-editor, and comments) with one import.

XRay component

XRay is the widget entrypoint exported by this package.

Props

  • root: string — absolute project root path
  • plugins?: XRayPlugin[] — plugin instances to mount
  • position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' — initial toolbar position

Plugin model

Plugins implement XRayPlugin:

interface XRayPlugin {
  name: string
  toolbar?: ComponentType
  actionPanel?: ComponentType
  settings?: ComponentType
}
  • toolbar renders inside the widget toolbar.
  • actionPanel renders inside the selected-component action menu.
  • settings renders inside the widget settings popover.

Plugin-owned components receive no props. Read shared widget state through the exported hooks instead.

Minimal plugin example

import { XRay, useSelectedContext, type XRayPlugin } from '@react-xray/core'

function SelectionInfo() {
  const context = useSelectedContext()
  return context ? <button type="button">{context.displayName}</button> : null
}

const examplePlugin: XRayPlugin = {
  name: 'Example',
  toolbar: SelectionInfo,
}

export function AppShell() {
  return <XRay root="/absolute/path/to/project" plugins={[examplePlugin]} />
}

Exported hooks

  • useProjectRoot() — returns the current project root string
  • useInspectorActive() — returns whether inspector mode is active
  • useDeactivateInspector() — returns a callback that turns inspector mode off
  • useSelectedContext() — returns the currently selected ComponentContext | null
  • useClearSelectedContext() — returns a callback that clears the current selection
  • useSelectedSource() — returns the currently selected ComponentSource | null
  • useWidgetPortalContainer() — returns the widget portal container element
  • useWidgetServices() — returns shared services such as fs

Exported utilities and constants

  • resolveSource(source) — resolves URL-based source locations back to original source-map positions when possible
  • toAbsolutePath(fileName, root?) — converts a source filename or Vite URL to an absolute filesystem path
  • toRelativePath(fileName, root?) — converts a source filename or Vite URL to a path relative to the project root when possible
  • settingsPluginAtom(pluginKey) — returns a writable Jotai atom for a section of XRaySettings
  • IS_MACtrue on macOS/iOS user agents
  • MOD_KEY — platform-specific modifier key label ( or Ctrl)

Exported types

  • ComponentContext
  • ComponentSource
  • FileSystemService
  • XRayPlugin
  • XRayProps
  • XRayServices
  • XRaySettings

Notes for plugin authors

  • useWidgetServices().fs exposes the file-system service used by official plugins.
  • useWidgetPortalContainer() lets plugin popovers, tooltips, and menus render inside the widget portal instead of document.body.
  • settingsPluginAtom() is keyed by XRaySettings, so plugin settings should live under a stable top-level key.

Production builds

This package publishes development and production entrypoints. In production mode, the exported XRay component resolves to a no-op stub, which keeps the inspector at zero runtime cost when production export conditions are used.