npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-google-login-ts

v1.0.2

Published

A TypeScript library for integrating Google login in React applications. Easily handle OAuth2 authentication using Google login API, including managing tokens and user data retrieval.

Readme

React Google Login Hook

A lightweight React hook package for implementing Google OAuth2 login functionality in React applications.

Features

  • Easy-to-use React hooks for Google OAuth2 integration
  • Handle Google login flow with minimal setup
  • Automatic window message handling
  • TypeScript support
  • Zero dependencies (other than React)

Installation

npm install react-google-login-ts

Or using yarn:

yarn add react-google-login-ts

Note: This package requires React 16.8.0 or higher as a peer dependency.

Usage

1. Set Up Google OAuth2

First, set up your Google OAuth2 credentials in the Google Cloud Console and get your Client ID.

2. Implement Login Button
import { googleLoginClick } from 'react-google-login-ts';

function LoginButton() {
   const handleLogin = () => {
      const clientId = 'YOUR_GOOGLE_CLIENT_ID';
      const redirectPath = 'http://your-domain.com/auth/callback';
      googleLoginClick(clientId, redirectPath);
   };

   return <button onClick={handleLogin}>Login with Google</button>;
}
3. Handle Redirect Page

Create a callback page component:

import { useRedirectPageGoogleLogin } from 'react-google-login-ts';

function GoogleCallback() {
   useRedirectPageGoogleLogin('YOUR_BACKEND_URL');
   return <div>Processing login...</div>;
}
4. Get Login Data

In your main component or where you need the login data:

import { useGetDataFromGoogleLogin } from 'react-google-login-ts';

function App() {
   const loginData = useGetDataFromGoogleLogin((data) => {
      console.log('Login successful:', data);
   });

   return <div>{loginData ? <div>Welcome, {loginData.name}!</div> : <LoginButton />}</div>;
}

API Reference

googleLoginClick
function googleLoginClick(clientId: string, redirectPath: string): void;

Opens the Google login window.

  • clientId: Your Google OAuth2 client ID
  • redirectPath: The URL where Google will redirect after authentication
useRedirectPageGoogleLogin
function useRedirectPageGoogleLogin(backendUrl: string): void;

Hook for handling the OAuth2 callback.

  • backendUrl: Your backend endpoint that handles the OAuth2 code exchange
useGetDataFromGoogleLogin
function useGetDataFromGoogleLogin(callback?: (data: any) => any): any;

Hook for receiving the login data.

  • callback: Optional callback function that runs when login data is received
  • Returns the login data object
📄 License

"This project is licensed under the MIT License - see the LICENSE.md file or details.


Made with ❤️ using TypeScript