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

github-contrib-graph

v3.0.2

Published

Lightweight, customizable GitHub contribution graph widget for any website

Readme

github-contribution-graph

A lightweight, customizable GitHub contribution graph widget for any website.

npm version npm downloads License

Installation

npm install github-contribution-graph

Quick Start

React

import { GitHubContributionGraph } from 'github-contribution-graph/react';
import 'github-contribution-graph/styles.css';

function App() {
  return (
    <GitHubContributionGraph
      username="octocat"
      theme="midnight"
      onDataLoaded={(data) => console.log('Loaded!', data)}
    />
  );
}

Vanilla JavaScript

import { GitHubContributionWidget } from 'github-contribution-graph/vanilla';
import 'github-contribution-graph/styles.css';

const widget = new GitHubContributionWidget({
  username: 'octocat',
  container: '#my-graph',
  theme: 'void',
});

widget.render();

Script Tag (CDN)

<link rel="stylesheet" href="https://unpkg.com/github-contribution-graph/dist/gh.css">
<div id="gh"
     data-login="octocat"
     data-show-thumbnail="true"
     data-show-header="true"
     data-show-footer="true"></div>
<script src="https://unpkg.com/github-contribution-graph/dist/browser.global.js"></script>

Data Attributes

| Attribute | Default | Description | |-----------|---------|-------------| | data-login | required | GitHub username | | data-show-thumbnail | "true" | Show/hide GitHub logo below graph | | data-show-header | "true" | Show/hide contribution count header | | data-show-footer | "true" | Show/hide legend footer |

React API

GitHubContributionGraph

import { GitHubContributionGraph } from 'github-contribution-graph/react';

<GitHubContributionGraph
  username="octocat"           // Required: GitHub username
  apiEndpoint="..."            // Optional: Custom API endpoint
  theme="default"              // Optional: Theme preset or custom config
  showHeader={true}            // Optional: Show contribution count header
  showFooter={true}            // Optional: Show legend footer
  showThumbnail={true}         // Optional: Show GitHub attribution
  className="my-class"         // Optional: CSS class
  style={{ margin: 20 }}       // Optional: Inline styles
  onDataLoaded={(data) => {}}  // Optional: Callback when data loads
  onError={(error) => {}}      // Optional: Callback on error
  onLoading={(loading) => {}}  // Optional: Callback on loading state change
/>

useContributionData Hook

import { useContributionData } from 'github-contribution-graph/react';

function CustomGraph() {
  const { data, loading, error, refetch } = useContributionData('octocat', {
    apiEndpoint: 'https://custom-api.com', // Optional
    autoFetch: true,                        // Optional: default true
  });

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <div>
      <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>
      <button onClick={refetch}>Refresh</button>
    </div>
  );
}

Vanilla JS API

GitHubContributionWidget

import { GitHubContributionWidget } from 'github-contribution-graph/vanilla';

const widget = new GitHubContributionWidget({
  username: 'octocat',           // Required: GitHub username
  container: '#my-graph',        // Optional: CSS selector or HTMLElement
  apiEndpoint: '...',            // Optional: Custom API endpoint
  theme: 'void',                 // Optional: Theme preset or custom config
  showHeader: true,              // Optional: Show contribution count header
  showFooter: true,              // Optional: Show legend footer
  showThumbnail: true,           // Optional: Show GitHub attribution
  onDataLoaded: (data) => {},    // Optional: Callback when data loads
  onError: (error) => {},        // Optional: Callback on error
});

// Methods
await widget.render();           // Render the widget
await widget.refresh();          // Refresh data and re-render
const data = widget.getData();   // Get current data
widget.destroy();                // Clear content
await widget.update({ ... });    // Update config and re-render

Themes

Built-in theme presets:

  • default - GitHub's default dark theme
  • void - Pure black minimalist
  • slate - Textured dark grey
  • midnight - Deep indigo/purple
  • glacier - Clean light theme
  • cyber - Neon green matrix style

Custom Theme

const widget = new GitHubContributionWidget({
  username: 'octocat',
  theme: {
    bgColor: '#1a1a2e',
    textColor: '#eaeaea',
    cellLevel0: '#16213e',
    cellLevel1: '#0f3460',
    cellLevel2: '#533483',
    cellLevel3: '#e94560',
    cellLevel4: '#ff6b6b',
    borderColor: '#0f3460',
  },
});

Self-Hosting the API

By default, the widget uses the hosted API at githubgraph.jigyansurout.com. To self-host:

  1. Clone the repository
  2. Deploy to Netlify (or similar)
  3. Set GITHUB_TOKEN environment variable (needs read:user scope)
  4. Use the apiEndpoint option to point to your deployment

Browser Support

  • Modern browsers (ES2020+)
  • Node.js 18+

License

Apache-2.0