react-google-button is a React component that provides a pre-styled Google Sign-In button, adhering to Google's official branding and style guidelines for identity solutions. The current stable version is 0.8.0, released in 2024. The package maintains a steady but not rapid release cadence, focusing on compatibility updates and minor feature enhancements. It ships with TypeScript types, offering a robust development experience for TypeScript users. Its primary differentiator is its simplicity and strict adherence to Google's visual guidelines, making it a drop-in solution for integrating Google authentication without manual styling efforts. It supports both modern ESM module environments and older CommonJS setups, and also offers UMD builds for direct browser script usage.
npm install react-google-buttonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and render the GoogleButton component, providing a basic onClick handler to simulate a sign-in attempt. It highlights the primary usage pattern.
Upgrade React and ReactDOM to version 16.8.0 or newer. `npm install react@^16.8.0 react-dom@^16.8.0` or `yarn add react@^16.8.0 react-dom@^16.8.0`.
Avoid using the `label` prop to override the default text unless absolutely necessary and you understand the implications for Google's branding.
Always access the component using `window.ReactGoogleButton` for UMD builds. Verify the global variable name in your specific build if encountering 'undefined' errors.
Always use the default import syntax: `import GoogleButton from 'react-google-button'`.
For CommonJS, use `const GoogleButton = require('react-google-button')`. Ensure your tooling correctly handles ESM default exports if you are transpiling.Change your import statement to `import GoogleButton from 'react-google-button'`. If using CommonJS, use `const GoogleButton = require('react-google-button')`.Ensure that `react` and `react-dom` are installed at version `16.8.0` or higher in your project's dependencies, and that there are no duplicate React installations. Use `npm ls react` or `yarn why react` to inspect versions.