Vue GitHub Buttons
Vue GitHub Buttons is a Vue 2 component library that provides pre-styled, functional components for displaying various GitHub buttons, such as 'watch', 'star', 'fork', and 'follow', complete with dynamic count fetching from the GitHub API. The latest stable version is 3.1.0, released in April 2020. Given the lack of activity since then, the project is considered abandoned, and no further updates or security patches are anticipated. Key features include built-in caching to mitigate GitHub API rate limits, and dedicated integration modules for Nuxt.js and VuePress 1.x. Version 3.0.0 marked a shift from Axios to the native Fetch API for network requests, which may necessitate polyfills for older browser environments.
Common errors
-
_ssrNode is not a function
cause An issue specifically related to server-side rendering (SSR) environments in older versions of the library, potentially due to incompatible rendering helpers.fixUpgrade to version 2.0.3 or higher, where this specific SSR rendering bug was addressed and fixed. -
ReferenceError: fetch is not defined
cause Occurs after upgrading to v3.0.0 in environments (older browsers, or specific Node.js versions before v3.1.0) that do not natively support the Fetch API, which v3.0.0 adopted.fixFor client-side, include a Fetch polyfill (e.g., `whatwg-fetch`) in your project. For Node.js (SSR), upgrade to v3.1.0 or newer which includes an internal `node-fetch` polyfill. -
GitHub API rate limit exceeded
cause Frequent requests to the GitHub API, especially unauthenticated ones, can quickly hit rate limits (e.g., 60 requests per hour for unauthenticated users), leading to API errors and buttons failing to display counts.fixEnsure `useCache: true` is enabled in the plugin options. For production applications with high traffic or many buttons, consider proxying GitHub API requests through your own backend to manage caching and potentially use a personal access token for higher limits.
Warnings
- breaking This package is incompatible with Vue 3. It explicitly requires Vue 2 as a peer dependency, and attempts to use it with Vue 3 will result in runtime errors due to fundamental API differences.
- breaking Version 3.0.0 replaced Axios with the native Fetch API for data fetching. Browsers without Fetch API support (e.g., Internet Explorer) will require a Fetch polyfill to function correctly.
- gotcha The GitHub API has strict rate limits, especially for unauthenticated requests. Excessive button rendering or frequent page refreshes can quickly hit these limits, leading to failed requests and blank button counts.
- gotcha For server-side rendering (SSR) environments, prior to v3.1.0, the package might encounter 'fetch is not defined' errors. While v3.1.0 introduced an internal `node-fetch` polyfill, potential edge cases or older Node.js versions might still expose this.
- breaking The package is considered abandoned as of April 2026, with its last update in April 2020. This means no new features, bug fixes, security patches, or compatibility updates for newer Vue versions (e.g., Vue 3) or browser changes are expected.
Install
-
npm install vue-github-buttons -
yarn add vue-github-buttons -
pnpm add vue-github-buttons
Imports
- VueGitHubButtons
const VueGitHubButtons = require('vue-github-buttons');import VueGitHubButtons from 'vue-github-buttons';
- CSS
import 'vue-github-buttons/dist/vue-github-buttons.css';
- Nuxt module
import VueGitHubButtonsModule from 'vue-github-buttons/nuxt';
module.exports = { modules: ['vue-github-buttons/nuxt'] }; - VuePress plugin
import VuePressPlugin from 'vue-github-buttons/plugins/vuepress';
module.exports = { plugins: [require('vue-github-buttons/plugins/vuepress')] };
Quickstart
import Vue from 'vue';
import VueGitHubButtons from 'vue-github-buttons';
import 'vue-github-buttons/dist/vue-github-buttons.css';
Vue.use(VueGitHubButtons, { useCache: true }); // Enable caching to reduce GitHub API calls
const App = {
template: `
<div id="app">
<h1>GitHub Buttons Example</h1>
<p>Star the Vue.js repository:</p>
<gh-btns-star slug="vuejs/vue" show-count></gh-btns-star>
<p>Follow Evan You (creator of Vue.js):</p>
<gh-btns-follow user="yyx990803" show-count></gh-btns-follow>
<p>Fork this project:</p>
<gh-btns-fork slug="gluons/vue-github-buttons" show-count></gh-btns-fork>
</div>
`
};
new Vue({
el: '#app',
render: h => h(App)
});