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

@helpin-ai/nextjs

v0.0.36

Published

Helpin JavaScript SDK for NextJS

Readme

@helpin-ai/nextjs

Helpin for Next.js. Drop-in analytics, chat widget control, and pageview tracking — with middleware support for server-side events.

Installation

npm install @helpin-ai/nextjs @helpin-ai/sdk-js

Quick Start

Create a client component that initializes Helpin and wraps your app:

'use client';

import { useMemo } from 'react';
import { createClient, HelpinProvider, usePageView } from '@helpin-ai/nextjs';

export function Providers({ children }: { children: React.ReactNode }) {
  const helpinClient = useMemo(
    () =>
      createClient({
        widgetKey: process.env.NEXT_PUBLIC_HELPIN_WIDGET_KEY!,
        host: process.env.NEXT_PUBLIC_HELPIN_HOST!,
        autoBoot: false,
      }),
    [],
  );

  usePageView(helpinClient);

  return <HelpinProvider client={helpinClient}>{children}</HelpinProvider>;
}

createClient(...) is browser-only and returns null during SSR. Always call it from a client component.

useHelpin()

The hook provides analytics, user identification, and widget control from any component in the tree:

'use client';

import { useEffect } from 'react';
import { useHelpin } from '@helpin-ai/nextjs';

export function BillingCTA() {
  const { id, track, lead, set, open } = useHelpin();

  useEffect(() => {
    void id({
      id: 'user_123',
      email: '[email protected]',
      first_name: 'Jane',
      last_name: 'Doe',
      company: {
        id: 'company_123',
        name: 'Acme Inc',
        created_at: '2024-01-15T00:00:00Z',
      },
    });
    set({ app: 'web' });
  }, [id, set]);

  return (
    <>
      <button onClick={() => track('billing_cta_clicked', { source: 'hero' })}>
        Talk to Sales
      </button>
      <button onClick={open}>Chat with us</button>
    </>
  );
}

Available methods

Analytics

| Method | Signature | Description | | --- | --- | --- | | trackPageView | () => void | Send a pageview event | | id | (userData, doNotSendEvent?) => Promise<void> | Identify the current user | | track | (eventName, payload?) => void | Track a custom event | | lead | (payload, directSend?) => void | Track a lead event | | rawTrack | (payload) => void | Send a raw event payload | | set | (properties, opts?) => void | Set global or event-scoped properties | | unset | (propertyName, opts?) => void | Remove a property added with set(...) |

Widget

| Method | Signature | Description | | --- | --- | --- | | show | () => void | Make the widget visible without opening chat | | hide | () => void | Hide the widget entirely | | open | () => void | Open the chat panel | | close | () => void | Close the chat panel while keeping the launcher visible | | toggle | () => void | Toggle the widget open or closed | | openMessages | () => void | Open the messages view | | openNewMessage | (content?) => void | Start a new conversation | | shutdown | () => void | End the session and unmount the widget |

For the complete client API (boot, group, reset, setUserId, getConfig, getLogger), use the object returned by createClient(...) directly.

usePageView()

Tracks client-side route changes automatically. Optionally run setup logic or attach extra data before each pageview fires:

'use client';

import { createClient, usePageView } from '@helpin-ai/nextjs';

const helpinClient = createClient({
  widgetKey: process.env.NEXT_PUBLIC_HELPIN_WIDGET_KEY!,
  host: process.env.NEXT_PUBLIC_HELPIN_HOST!,
});

export function PageViewTracker() {
  usePageView(helpinClient, {
    before: (client) => {
      void client.id({ id: 'user_123', email: '[email protected]' });
    },
    payload: {
      framework: 'nextjs',
    },
  });

  return null;
}

| Option | Type | Description | | --- | --- | --- | | before | (helpin) => void | Runs before each pageview event | | typeName | string | Custom event name (default: pageview) | | payload | EventPayload | Extra fields merged into the payload |

Server-Side Tracking

For server-side analytics in middleware, route handlers, or server actions, pair the core SDK with middlewareEnv(...). It extracts request metadata and manages the anonymous visitor ID cookie:

import { NextRequest, NextResponse } from 'next/server';
import { helpinClient } from '@helpin-ai/sdk-js';
import { middlewareEnv } from '@helpin-ai/nextjs';

const client = helpinClient({
  widgetKey: process.env.NEXT_PUBLIC_HELPIN_WIDGET_KEY!,
  host: process.env.NEXT_PUBLIC_HELPIN_HOST!,
});

export function middleware(req: NextRequest) {
  const res = NextResponse.next();
  const env = middlewareEnv(req, res);

  client?.track('pageview', {
    ...env.describeClient(),
    source_ip: env.getSourceIp(),
    anonymous_id: env.getAnonymousId({
      name: 'helpin_aid',
      domain: '.example.com',
    }),
  });

  return res;
}

| Method | Description | | --- | --- | | getAnonymousId({ name, domain? }) | Return or create the anonymous visitor ID cookie | | getSourceIp() | Extract the client IP from request headers | | describeClient() | Build a ClientProperties object from the request |

Client vs. Server

| Context | What to use | | --- | --- | | Browser (analytics + widget) | createClient(...) from @helpin-ai/nextjs | | Server (middleware, route handlers, server actions) | helpinClient(...) from @helpin-ai/sdk-js + middlewareEnv(...) |

The chat widget boots automatically in the browser when widgetKey and host are set. Pass autoBoot: false to keep it dormant until you call show(), open(), or openNewMessage() — useful for custom launchers.

Exports

| Export | Description | | --- | --- | | createClient | Browser-only client factory | | HelpinProvider | React context provider | | HelpinContext | Raw React context (for advanced use) | | useHelpin | Analytics and widget hook | | usePageView | Automatic pageview tracking hook | | middlewareEnv | Next.js middleware helper |

Development

pnpm --filter @helpin-ai/nextjs build
pnpm --filter @helpin-ai/nextjs test