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

react-git-history-viewer

v2.0.4

Published

A React component to display Git history and version information.

Downloads

784

Readme

React Git History Viewer

A React component that displays git version information and provides an interactive git history browser for development environments.

Features

  • Dynamic Versioning: A CLI tool to generate a major.minor version number based on the total number of git commits.
  • Environment-Specific Display: Shows only a minimal version badge in production and a full interactive panel in development.
  • Framework Agnostic Component: The core component can be used in any React project. An example API handler for Next.js is provided.

Installation

npm install react-git-history-viewer

How to Use (Next.js App Router Example)

Step 1: Add the Version Script

In your project's package.json, add a script to generate the version file using the package's built-in CLI.

"scripts": {
  "version": "create-git-version"
}

Step 2: Generate the Version File

Before committing and deploying your code, run the version script. This will create a version.json file in your public directory.

npm run version

Important: You must commit the generated public/version.json file to your repository.

Step 3: Set up the API Handler

The interactive panel requires an API endpoint to fetch git data.

  1. Create a new API route in your project at app/api/git-history/route.ts.
  2. Import and use the gitHistoryHandler from the package.
// app/api/git-history/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { gitHistoryHandler } from 'react-git-history-viewer/dist/api-handler';

export async function GET(request: NextRequest) {
  const searchParams = request.nextUrl.searchParams;
  const author = searchParams.get('author') || undefined;
  const hash = searchParams.get('hash') || undefined;

  const result = await gitHistoryHandler({ author, hash });
  
  return NextResponse.json(result.body, { status: result.status });
}

Step 4: Use the Component in Your App

Import and render the GitHistoryViewer component in a Client Component.

'use client';

import { GitHistoryViewer } from 'react-git-history-viewer';

export default function MyLayout({ children }) {
  return (
    <div>
      {/* Your app content */}
      
      <GitHistoryViewer 
        apiBasePath="/api" 
        devMode={process.env.NODE_ENV === 'development'} 
      />
    </div>
  );
}

Props

  • apiBasePath (string, required): The base path for your API routes (e.g., /api).
  • devMode (boolean, optional, default: false): Set to true to enable the interactive history panel. It is highly recommended to tie this to an environment variable like process.env.NODE_ENV === 'development'.