A tiny React hook that simplifies the process of using the Google Identity Service in a React application
npm
npm install use-gsi
yarn
yarn add use-gsi
Get your Google API client ID
import React from "react";
import { useGSI } from "use-gsi";
export default function App() {
const [data, setData] = useState({});
const { buttonRef } = useGSI({
initializeConfig: {
//Google API client ID
client_id: clientId,
callback: (response) => setData(response),
},
method: "renderButton",
buttonConfig: {
theme: "outline",
type: "standard",
},
});
console.log(data);
return <div ref={buttonRef} />;
}
// TODO
The MIT License.