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

@buildninja/git-graph-svg

v2.0.6

Published

Lightweight SVG-based Git commit graph renderer for React with automatic branch layout.

Readme

@buildninja/git-graph-svg

React component for rendering Git commit histories as SVG graphs. It draws commit nodes, parent connections, branches, and merges. The package exports GitGraph and the earlier GitGraphSVG component.

Examples

Git graph examples

More Git graph examples

Use in a React application

The consuming application needs React 18 or later and react-dom 18 or later.

Install the package from npm:

npm install @buildninja/git-graph-svg

To test an unpublished change locally, build and pack this repository:

npm install
npm run build
npm pack

This creates a buildninja-git-graph-svg-<version>.tgz file. In the consuming application, install that file using its actual path:

npm install /path/to/buildninja-git-graph-svg-<version>.tgz

The package is published publicly under the @buildninja npm organization.

Basic example

import { GitGraph, type ICommitItem } from "@buildninja/git-graph-svg";

const commits: ICommitItem[] = [
  {
    id: "b2",
    message: "Add feature",
    author: "Developer",
    date: "2026-02-18T10:30:12Z",
    parents: ["a1"],
  },
  {
    id: "a1",
    message: "Initial commit",
    author: "Developer",
    date: "2026-02-18T09:12:45Z",
    parents: [],
  },
];

export default function CommitHistory() {
  return <GitGraph commits={commits} />;
}

Each commit needs a unique id, message, author, parseable date, and parents array. Parent IDs refer to other commits in the input; use an empty array for a root commit. The graph sorts commits by date from newest to oldest and adds layout data to each commit's optional meta field. It mutates the input array and commit objects, so pass a copy if the application needs to preserve the original data.

const graphCommits = commits.map((commit) => ({
  ...commit,
  parents: [...commit.parents],
  meta: commit.meta
    ? { ...commit.meta, prev: [...(commit.meta.prev ?? [])] }
    : undefined,
}));

<GitGraph commits={graphCommits} />;

Configuration

| Prop | Purpose | | --- | --- | | commits | Required array of ICommitItem records. | | colorPalette | Colors assigned to branches. | | padding | SVG padding as one number or { left, right, top, bottom }. | | rowHeight | Vertical spacing between commits. Default: 35. | | laneWidth | Horizontal spacing between branch lanes. Default: 35. | | style | CSS properties applied to the SVG element. | | renderNode | Custom node renderer: (x, y, color, commit) => ReactNode. | | renderEdge | Custom edge renderer: (from, to, path, color) => ReactNode. | | getMergeCurve | Custom SVG path segment for a merge. | | getBranchSplitCurve | Custom SVG path segment for a branch split. |

For example, customize nodes and edges:

<GitGraph
  commits={commits}
  rowHeight={40}
  colorPalette={["#3a86ff", "#8338ec", "#ff006e"]}
  renderNode={(x, y, color, commit) => (
    <circle key={commit.id} cx={x} cy={y} r={5} fill={color} />
  )}
  renderEdge={(from, to, path, color) => (
    <path
      key={`${from.id}-${to.id}`}
      d={path}
      stroke={color}
      strokeWidth={2}
      fill="none"
    />
  )}
/>

Work on this package

npm install
npm run dev

Run npm run build to generate the distributable files in dist, and npm run lint to check the source.

Repository

Source and issue tracking: BuildNinja-CICD/buildninja-git-graph-svg.