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.
Powered by
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:
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:
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.
Prop | Type | Default | Description |
---|---|---|---|
username | string | required | GitHub username or organization |
repo | string | required | Repository name to fetch stars from |
formatted | boolean | false | Use compact notation (1.2k) instead of full numbers |
transition | SpringOptions | { stiffness: 90, damping: 50 } | Spring physics configuration for counting |
inView | boolean | false | Enable intersection observer triggering |
inViewMargin | string | "0px" | Margin for viewport detection |
inViewOnce | boolean | true | Animate only on first viewport entry |
className | string | - | Additional CSS classes for styling |
onClick | () => void | Opens repo | Custom 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:
Count | Unformatted | Formatted |
---|---|---|
567 | 567 | 567 |
1,234 | 1,234 | 1.2k |
45,678 | 45,678 | 45.7k |
123,456 | 123,456 | 123k |
1,234,567 | 1,234,567 | 1.2M |
12,345,678 | 12,345,678 | 12.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:
Copy Button
One-click clipboard copying with animated feedback
Ripple Button
Material Design ripple effects from click position
Liquid Button
Fluid fill animations that flow on interaction
Flip Button
3D flip animations revealing hidden content
Questions developers actually ask
React Flip Button
React flip button with 3D animations that reveal hidden messages on hover. Smooth transitions and customizable directions with TypeScript and shadcn/ui.
React Icon Button
React icon button with particle burst and glow effects on activation. Lucide icons with smooth animations, TypeScript support, and shadcn/ui styling.