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

@zetalyx/react

v2.2.0

Published

Zetalyx SDK for React applications

Readme

@zetalyx/react

React bindings for Zetalyx — Provider, hooks, error boundary, and HOC for React applications.

Installation

npm install @zetalyx/react @zetalyx/browser

Quick Start

1. Wrap your app with the provider

import { ZetalyxProvider } from '@zetalyx/react';

function App() {
  return (
    <ZetalyxProvider apiKey="pk_live_your_api_key" userId="user_123">
      <YourApp />
    </ZetalyxProvider>
  );
}

2. Use hooks in any component

import { useTrack, useTrackError, useTrackBehavior, useIdentify } from '@zetalyx/react';

function Dashboard() {
  const track = useTrack();
  const trackError = useTrackError();
  const trackBehavior = useTrackBehavior();
  const identify = useIdentify();

  useEffect(() => {
    track('dashboard_viewed');
  }, []);

  const handleClick = () => {
    trackBehavior('export_clicked', { format: 'csv' });
  };

  return <button onClick={handleClick}>Export</button>;
}

Provider

<ZetalyxProvider
  apiKey="pk_live_..."        // Required
  userId="user_123"           // Optional — auto-calls identify()
  endpoint="https://..."      // Default: 'https://api.zetalyx.com'
  batchSize={10}              // Flush after N events
  flushInterval={5000}        // Flush every N ms
  debug={false}               // Console debug logging
  autoCapture={true}          // Auto-capture window errors
  captureClicks={false}       // Auto-track interactive element clicks
>
  {children}
</ZetalyxProvider>

The provider creates a BrowserClient instance and manages its lifecycle. It automatically shuts down the client on unmount.

Hooks

useZetalyx()

Access the underlying BrowserClient instance directly.

const client = useZetalyx();
await client.flush();

useTrack()

Returns a stable callback for tracking custom events.

const track = useTrack();
track('feature_used', { feature: 'dark_mode' });

useTrackError()

Returns a stable callback for tracking errors.

const trackError = useTrackError();

try {
  await fetchData();
} catch (err) {
  trackError(err, { context: 'data_fetch' });
}

useTrackBehavior()

Returns a stable callback for tracking user behaviors.

const trackBehavior = useTrackBehavior();
trackBehavior('form_submitted', { form: 'contact' });

useIdentify()

Returns a stable callback for identifying users.

const identify = useIdentify();

// After login
identify(user.id, { email: user.email, plan: user.plan });

Error Boundary

Automatically catches React render errors and reports them to Zetalyx.

import { ZetalyxErrorBoundary } from '@zetalyx/react';

// With a static fallback
<ZetalyxErrorBoundary fallback={<div>Something went wrong</div>}>
  <RiskyComponent />
</ZetalyxErrorBoundary>

// With a render function (includes error and reset)
<ZetalyxErrorBoundary
  fallback={(error, reset) => (
    <div>
      <p>Error: {error.message}</p>
      <button onClick={reset}>Try Again</button>
    </div>
  )}
  metadata={{ section: 'dashboard' }}
  onError={(error, errorInfo) => console.error(error)}
>
  <RiskyComponent />
</ZetalyxErrorBoundary>

The error boundary automatically includes the React component stack in the error report.

Higher-Order Component

For class components or when you prefer the HOC pattern:

import { withZetalyx, type WithZetalyxProps } from '@zetalyx/react';

interface Props extends WithZetalyxProps {
  title: string;
}

function MyComponent({ title, zetalyx }: Props) {
  const handleClick = () => {
    zetalyx.track('clicked', { title });
  };

  return <button onClick={handleClick}>{title}</button>;
}

export default withZetalyx(MyComponent);

Full Example

import {
  ZetalyxProvider,
  ZetalyxErrorBoundary,
  useTrack,
  useTrackBehavior,
  useIdentify,
} from '@zetalyx/react';

function App() {
  const [user, setUser] = useState(null);

  return (
    <ZetalyxProvider
      apiKey="pk_live_your_api_key"
      userId={user?.id}
      captureClicks
    >
      <ZetalyxErrorBoundary
        fallback={(error, reset) => (
          <div>
            <h2>Something went wrong</h2>
            <button onClick={reset}>Retry</button>
          </div>
        )}
      >
        <Dashboard />
      </ZetalyxErrorBoundary>
    </ZetalyxProvider>
  );
}

License

MIT