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

@forthtilliath/preact-toc

v0.1.0

Published

Headless hook to auto-generate a scrollspy table of contents from your page's headings, for Preact.

Readme

📑 Preact TOC

License npm Preact TypeScript Tailwind CSS

Un hook headless pour Preact qui génère automatiquement un sommaire ("On this page") à partir des titres de ta page, avec mise en surbrillance de la section active au scroll (scrollspy) — comme sur la documentation de Stripe, Tailwind ou shadcn/ui.

🔗 Démo : preact-page-navigation.vercel.app

Sommaire généré automatiquement, avec la section "Installation" active en surbrillance pendant le scroll

Pourquoi

Générer un sommaire qui reste synchronisé avec le scroll de la page est un besoin récurrent (documentation, articles longs, changelogs...), mais implique de la logique répétitive : parcourir les titres, construire une arborescence, observer les sections visibles. Ce package encapsule tout ça dans un seul hook, sans imposer de style — à toi de brancher ta propre UI (Sidebar, Nav, etc.) par-dessus.

Installation

npm install @forthtilliath/preact-toc
# ou
pnpm add @forthtilliath/preact-toc

preact (>=10) est requis en peer dependency.

Usage

import { useNavigation, H2, H3 } from "@forthtilliath/preact-toc";

function Article() {
  const [articleRef, items, activeId] = useNavigation();

  return (
    <>
      <article ref={articleRef}>
        <H2>Installation</H2>
        <p>...</p>

        <H3>Prérequis</H3>
        <p>...</p>

        <H2>Usage</H2>
        <p>...</p>
      </article>

      {/* À toi de construire ta propre sidebar avec `items` et `activeId` */}
      <MySidebar items={items} active={activeId} />
    </>
  );
}

API

| Export | Description | | ---------------------------- | ------------------------------------------------------------------------------------------------ | | useNavigation(dataAnchor?) | Hook principal. Retourne [ref, items, activeId] : ref à poser sur le conteneur de l'article, items l'arborescence du sommaire, activeId l'id de la section actuellement visible. | | useActiveItem(elements) | Hook bas niveau : observe une liste d'éléments (IntersectionObserver) et retourne l'id de celui actuellement visible. | | buildNavigationStructure(headings) | Construit l'arborescence Item[] à partir d'une liste de titres HTML (H2 → H6). | | H2 / H3 / H4 | Composants de titre prêts à l'emploi : génèrent un id à partir du texte et l'attribut data-anchor nécessaire au hook. |

Ce que contient ce repo

  • lib/ — le code source du package publié sur npm (headless, sans dépendance de style).
  • src/ — une application de démo Preact + Tailwind CSS v4 montrant une intégration complète avec une sidebar stylée, déployée sur Vercel.

Développement

# installer les dépendances
bun install

# lancer la démo en local
bun run dev

# builder le package (dist-lib/)
bun run build:lib

Licence

Distribué sous licence MIT.