GitHub Stars Button

Link button showing a GitHub repo's star count with the octocat icon. Async server component — fetches data at build time with ISR.

Preview

Installation

$ shadcn add https://ui.justinlevine.me/r/github-stars-button.json

Usage

import { GitHubStarsButton } from "@/components/github-stars-button"
<GitHubStarsButton owner="shadcn-ui" repo="ui" />

Async server component. Fetches the GitHub API at build time and caches the result for 1 hour via Next.js ISR. No API key required — set GITHUB_TOKEN to raise the rate limit from 60 to 5,000 requests/hour.

Playground

Props

import { GitHubStarsButton } from "@/components/github-stars-button"

<GitHubStarsButton owner="shadcn-ui" repo="ui" />

Examples

Variants

Default

Secondary

Outline

Ghost

Subtle

Sizes

Small

Default

Large

With repo name

Default + Repo

Secondary + Repo

Outline + Repo

Icon styles

Current Color

GitHub Green

Copilot Purple

Secondary + GitHub Green

Secondary + Copilot Purple

API Reference

GitHubStarsButton

PropType

Notes

  • ISR caching. Results cached for 1 hour via next.revalidate.
  • Pre-fetched stars. Pass the stars prop to skip the API call entirely.