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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@koharakazuya/nextjs-component-catalog

v0.4.0

Published

CLI to generate component catalog for Next.js (App Router)

Readme

Next.js Component Catalog

Next.js (App Router) アプリケーション開発でコンポーネントカタログを提供します。

使い方

1. ソースコード中の任意の箇所にカタログファイルを作成する

ファイル名は *.catalog.jsx*.catalog.tsx である必要があります。

推奨: コンポーネントの実装ファイルの隣に配置することを推奨します。

例:

Example/
  index.ts
  Example.tsx
  Example.catalog.tsx

2. カタログファイルにコンポーネントの使用例を実装し、名前付きでエクスポートする

エクスポートで使用した名前はパスとして使用されます。

特定のコンテナサイズや背景色、中央揃えなどのレイアウトでコンポーネントを動かしたい場合はここで調整してください。

例:

import Example from "./Example";

export function Default() {
  return <Example />;
}

export function Checked() {
  return <Example checked />;
}

3. ビルドを実行してページを生成する

$ npx nextjs-component-catalog build

を実行してください。ソースコード中のカタログファイルの定義から app/ ディレクトリ以下に Next.js のルート定義ファイルが生成されます。

Next.js を起動し、カタログのページ (デフォルトでは /dev/catalog) にアクセスするとカタログを確認できます。

$ npx nextjs-component-catalog build --watch

で監視モードで起動することもできます。

プロジェクトルートに .nextjs-component-catalogrc という JSON ファイルを作成すると設定を変更することができます。詳細は <./src/generator.ts> の Options を参照してください。

仕組み

このツールのコア部分の大まかな仕組みは以下の通りです。

  • 特定ディレクトリ以下の *.catalog.tsx などを監視
  • カタログファイルを見つけたら、ファイル内容をパースし、export 構文からシンボルを取得
  • カタログファイルに対応するパスとなるよう app/ 以下にファイルを生成 (ファイルの内容はカタログファイルを読み込み表示するだけのページコンポーネント)

Storybook との比較

コンポーネントカタログツールが必要な場合、基本的には Storybook を使用することを推奨します。

以下の観点で Storybook が適さずこのツールが必要になる場合があります。

  • Storybook が Next.js とは別のビルドチェーンを持っていることにより、セットアップの手間が大きすぎるもしくは一部のビルド機能が再現できない
  • アプリケーション全体で設定している機能 (共通の認証や React Context など) を Next.js 側と Storybook 側で多重に管理したくない
  • コンポーネントカタログをアプリケーションに埋め込みたい
  • もっとシンプルにしたい
  • もっとビルドを速くしたい

このような観点がない場合、Storybook は多数の非常に洗練された機能を持つためデフォルトで便利です。