
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
github-contrib-graph
Advanced tools
Lightweight, customizable GitHub contribution graph widget for any website
A lightweight, customizable GitHub contribution graph widget for any website.
npm install github-contribution-graph
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)}
/>
);
}
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();
<link rel="stylesheet" href="https://unpkg.com/github-contribution-graph/dist/gh.css">
<div id="gh" data-login="octocat"></div>
<script src="https://unpkg.com/github-contribution-graph/dist/browser.global.js"></script>
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
/>
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>
);
}
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
Built-in theme presets:
default - GitHub's default dark themevoid - Pure black minimalistslate - Textured dark greymidnight - Deep indigo/purpleglacier - Clean light themecyber - Neon green matrix styleconst widget = new GitHubContributionWidget({
username: 'octocat',
theme: {
bgColor: '#1a1a2e',
textColor: '#eaeaea',
cellLevel0: '#16213e',
cellLevel1: '#0f3460',
cellLevel2: '#533483',
cellLevel3: '#e94560',
cellLevel4: '#ff6b6b',
borderColor: '#0f3460',
},
});
By default, the widget uses the hosted API at github-contribution-graph.netlify.app. To self-host:
GITHUB_TOKEN environment variable (needs read:user scope)apiEndpoint option to point to your deploymentApache-2.0
FAQs
Lightweight, customizable GitHub contribution graph widget for any website
The npm package github-contrib-graph receives a total of 4,436 weekly downloads. As such, github-contrib-graph popularity was classified as popular.
We found that github-contrib-graph demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.