github-stars

This skill should be used when adding GitHub star counts, star buttons, star widgets, or GitHub social proof to a website or app. Applies when the user says "add GitHub stars", "show star count", "add a star badge", "GitHub badge", "star widget", "GitHub social proof", "stargazer count", or wants to display how many stars a repo has on a marketing page, header, or landing page. Also applies when integrating the GitHub API for repository metadata display.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "github-stars" with this command: npx skills add b-open-io/prompts/b-open-io-prompts-github-stars

GitHub Star Count Integration

Add live GitHub star counts to websites as social proof. Two patterns depending on traffic level — pick the right one and go.

Decision: Client-Side vs Server-Side

Client-side hook (default) — fetch directly from GitHub API in the browser.

  • No API key needed for public repos
  • GitHub allows 60 requests/hour per IP (unauthenticated)
  • Fine for most sites — each visitor makes their own request
  • Star count simply doesn't render if the fetch fails

Server-side caching — proxy through your own API route with a GITHUB_TOKEN.

  • Raises the limit to 5,000 requests/hour
  • Add next: { revalidate: 300 } to cache for 5 minutes
  • Use this for high-traffic pages or when you need the count at build time

Client-Side Hook

import { useEffect, useState } from "react";

export function useGitHubStars(repo: string) {
  const [stars, setStars] = useState<number | null>(null);

  useEffect(() => {
    fetch(`https://api.github.com/repos/${repo}`)
      .then((res) => res.json())
      .then((data) => {
        if (data.stargazers_count !== undefined) {
          setStars(data.stargazers_count);
        }
      })
      .catch(() => {}); // Intentional: star count is non-critical social proof — icon renders without it
  }, [repo]);

  return stars;
}

Display Pattern

import { Github } from "lucide-react";

const stars = useGitHubStars("owner/repo");

<a
  href="https://github.com/owner/repo"
  target="_blank"
  rel="noopener noreferrer"
  className="inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
>
  <Github className="h-4 w-4" />
  {stars !== null && <span className="text-xs tabular-nums">{stars}</span>}
</a>

Why tabular-nums: prevents layout shift as the digit count changes — all numerals occupy the same width.

Why stars !== null: the GitHub icon always renders; the count only appears after the fetch succeeds. If GitHub is down or rate-limited, the link still works as a plain GitHub link.

For More

Read references/patterns.md for:

  • Server-side caching API route (Next.js)
  • Mobile-responsive display (collapsed on small screens, badge on large)
  • Rate limit details and when to add a token
  • Animated star count (number counting up on mount)
  • Reference implementation from our theme-token project

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

cli-demo-gif

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

devops-scripts

No summary provided by upstream source.

Repository SourceNeeds Review
Research

x-research

No summary provided by upstream source.

Repository SourceNeeds Review
General

geo-optimizer

No summary provided by upstream source.

Repository SourceNeeds Review