Join our Discord Community

React GitHub Stars Button

React GitHub stars button with live API counts and particle effects. Social proof component with animated transitions, TypeScript, and shadcn/ui styling.

Building social proof components?

Join our Discord community for help from other developers.


GitHub stars are the ultimate developer flex. But most star buttons are just boring static badges. No animation. No life. Meanwhile, your open source project worked hard for those stars—they deserve a celebration. This React component fetches live star counts and animates them with particle explosions that make every star feel earned.

Live GitHub stars with particle effects

Watch real star counts animate with golden particle bursts on interaction:

Loading component...

Built for React applications with TypeScript and Next.js. Fetches live data from GitHub's API with automatic formatting (1.2k, 45.3k, 2.1M). The number animation uses Framer Motion springs for natural counting, while particle effects celebrate each interaction. Works seamlessly with shadcn/ui design systems.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json
npx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json
bunx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json

Usage

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

export default function ProjectShowcase() {
  return (
    <div className="flex gap-4">
      {/* Standard display with full numbers */}
      <GitHubStarsButton
        username="shadcn"
        repo="ui"
      />
      
      {/* Compact formatting for large numbers */}
      <GitHubStarsButton
        username="vercel"
        repo="next.js"
        formatted={true}
      />
      
      {/* Trigger animation when scrolled into view */}
      <GitHubStarsButton
        username="facebook"
        repo="react"
        formatted={true}
        inView={true}
        inViewMargin="-100px"
      />
    </div>
  );
}

Why most social proof buttons suck

Static badges are everywhere. Those lifeless shields.io images. Zero interaction. Zero delight. They treat your hard-earned stars like a boring metric instead of the social validation they represent.

Most developers slap a static SVG badge and move on. Or worse, they hardcode the star count and forget to update it. This React component connects to GitHub's API, fetches real numbers, and makes them feel alive with spring animations and particle celebrations.

The particle burst isn't just eye candy—it's psychological. Users see the particles and subconsciously connect stars with celebration. That tiny dopamine hit makes them more likely to star your repo too. Social proof that actually works.

Examples

Formatted Numbers

Compact notation for repositories with thousands or millions of stars:

Loading component...

Features

  • Live GitHub API integration fetching real-time star counts from any public repository
  • Animated number counting with spring physics that feel natural, not robotic
  • Golden particle explosions celebrating interactions with randomized burst patterns
  • Smart number formatting automatically switching between full and compact notation (1.2k, 45M)
  • Intersection Observer support triggering animations when scrolled into viewport
  • Progressive star filling with the icon animating as numbers count up
  • TypeScript definitions with complete GitHub API types and animation configurations
  • Error resilience gracefully handling API limits and network failures
  • Accessible button semantics with proper ARIA labels and keyboard support

API Reference

GitHubStarsButton

The main component for displaying GitHub repository stars with animations.

PropTypeDefaultDescription
usernamestringrequiredGitHub username or organization
repostringrequiredRepository name to fetch stars from
formattedbooleanfalseUse compact notation (1.2k) instead of full numbers
transitionSpringOptions{ stiffness: 90, damping: 50 }Spring physics configuration for counting
inViewbooleanfalseEnable intersection observer triggering
inViewMarginstring"0px"Margin for viewport detection
inViewOncebooleantrueAnimate only on first viewport entry
classNamestring-Additional CSS classes for styling
onClick() => voidOpens repoCustom click handler override

Spring Configuration

Control the counting animation feel:

// Smooth, natural counting (default)
transition={{ stiffness: 90, damping: 50 }}

// Snappy, quick counting
transition={{ stiffness: 200, damping: 40 }}

// Bouncy, playful counting
transition={{ stiffness: 60, damping: 20 }}

// Slow, dramatic reveal
transition={{ stiffness: 40, damping: 60 }}

Number Formatting

The component automatically formats based on size:

CountUnformattedFormatted
567567567
1,2341,2341.2k
45,67845,67845.7k
123,456123,456123k
1,234,5671,234,5671.2M
12,345,67812,345,67812.3M

Common gotchas

GitHub API rate limits: Unauthenticated requests are limited to 60 per hour per IP. The component caches responses, but rapid refreshes during development can hit limits. Consider implementing server-side caching.

Private repositories: The component only works with public repos. Private repos return 404 even with authentication. There's no workaround due to GitHub's API design.

Initial loading state: The button shows "0" while fetching. For better UX, consider skeleton loading or server-side data fetching to avoid the jump from 0 to actual count.

Particle performance: The particle effects use multiple DOM elements. On low-end devices with many buttons, consider reducing particle count or disabling on mobile.

Click delay: The button delays navigation by 500ms to show the particle effect. If this feels slow, reduce the delay in the onClick handler or remove it entirely.

Number formatting edge cases: Very large numbers (billions) might overflow button width. Test with repos like freeCodeCamp/freeCodeCamp to ensure your layout handles edge cases.

You might also like

Explore other interactive button components for React applications:

Questions developers actually ask