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-spotlight-onboard

v1.0.0

Published

Zero-dependency React onboarding tour with SVG spotlight, smart tooltip placement, and keyboard navigation.

Downloads

13

Readme

react-spotlight-onboard

Zero-dependency React onboarding tour with SVG spotlight, smart tooltip placement, and keyboard navigation.

Live Demo

  • No external dependencies — built entirely with React + TypeScript
  • SVG spotlight — smooth cutout effect that works with any layout (no z-index hacks)
  • Smart placement — tooltip auto-positions to avoid viewport edges
  • Keyboard navigation next, back, Escape to skip
  • Next.js App Router ready — all client components marked with "use client"
  • Fully typed — complete TypeScript types included

Installation

npm install react-spotlight-onboard
# or
pnpm add react-spotlight-onboard
# or
yarn add react-spotlight-onboard

Quick Start

1. Wrap your app with TourProvider

// app/layout.tsx or a providers file ("use client" required)
import { TourProvider } from "react-spotlight-onboard";

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <TourProvider>
      {children}
    </TourProvider>
  );
}

2. Mark target elements with data-tour-id

<nav data-tour-id="sidebar-nav">...</nav>
<header data-tour-id="main-header">...</header>
<div data-tour-id="dashboard-stats">...</div>

3. Start the tour

"use client";
import { useOnboardingTour } from "react-spotlight-onboard";
import { useEffect } from "react";

export function DashboardPage() {
  const { startTour } = useOnboardingTour();

  useEffect(() => {
    startTour(
      "dashboard",
      [
        {
          id: "step-1",
          target: "sidebar-nav",
          title: "Navigation",
          description: "Use the sidebar to move between sections.",
        },
        {
          id: "step-2",
          target: "main-header",
          title: "Header",
          description: "Your account and settings are up here.",
          placement: "bottom",
        },
        {
          id: "step-3",
          target: "dashboard-stats",
          title: "Dashboard",
          description: "Your key metrics at a glance.",
          placement: "top",
        },
      ],
      {
        onComplete: (tourId) => {
          localStorage.setItem(`tour-${tourId}-done`, "true");
        },
        onSkip: (tourId, stepIndex) => {
          console.log(`Skipped tour "${tourId}" at step ${stepIndex}`);
        },
      }
    );
  }, []);

  return <main>...</main>;
}

API

<TourProvider>

Wrap your app once. Renders the spotlight overlay automatically when a tour is active.

| Prop | Type | Default | Description | |------|------|---------|-------------| | zIndex | number | 9000 | z-index of the overlay stack | | backdropOpacity | number | 0.6 | Darkness of the backdrop (0–1) |

useOnboardingTour()

const {
  startTour,        // (tourId, steps, callbacks?) => void
  stopTour,         // () => void — stops without firing onSkip
  nextStep,         // () => void
  prevStep,         // () => void
  skipTour,         // () => void — fires onSkip callback
  isActive,         // boolean
  activeTourId,     // string | null
  currentStep,      // TourStep | null
  currentStepIndex, // number
  totalSteps,       // number
} = useOnboardingTour();

TourStep

interface TourStep {
  id: string;
  target: string;              // matches data-tour-id="..." on a DOM element
  title: string;
  description: string;
  placement?: "top" | "bottom" | "left" | "right" | "auto"; // default: "auto"
  spotlightPadding?: number;   // px padding around the spotlight cutout; default: 8
  customContent?: ReactNode;   // rendered below the description
}

Callbacks

startTour("my-tour", steps, {
  onComplete: (tourId: string) => void,
  onSkip: (tourId: string, stepIndex: number) => void,
  onStepChange: (tourId: string, step: TourStep, index: number) => void,
});

Keyboard Shortcuts

| Key | Action | |-----|--------| | ArrowRight | Next step | | ArrowLeft | Previous step | | Escape | Skip tour |

How It Works

The spotlight effect uses an SVG mask that cuts a rounded rectangle hole over the target element. This approach is immune to CSS stacking context issues that affect clip-path-based approaches — it works correctly inside sidebars, modals, and transformed containers.

Target elements are resolved via document.querySelector('[data-tour-id="..."]'). The tooltip placement algorithm measures available viewport space in all four directions and picks the side with the most room, clamping the position to always stay within the viewport.

Next.js App Router

All interactive components include the "use client" directive. Place TourProvider inside a Client Component boundary:

// providers.tsx
"use client";
import { TourProvider } from "react-spotlight-onboard";

export function Providers({ children }: { children: React.ReactNode }) {
  return <TourProvider>{children}</TourProvider>;
}
// app/layout.tsx (Server Component)
import { Providers } from "./providers";

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}

License

MIT