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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-new-google-login

v0.1.5

Published

React New Google Login component

Downloads

4

Readme

New Google Login for React

The Google Sign-In JavaScript Platform Library for web has been deprecated and will not work for existing uses after Mar 31, 2023 nor for newly created Google Cloud projects.

This React component creates a Google Login button using the new Google Identity Service for Web introduced in early 2022 and on successful login generates a JWT that can be used to authenticate other Google or custom services.

Installation

npm install --save react-new-google-login

Usage

import {useState} from 'react';
import GoogleLogin from 'react-new-google-login';

const App = () => {

  const [token, setToken] = useState('');
  const signin = (token) => setToken(token);
  const error = (err) => console.log(err);
  const CLIENT_ID = 'google-client-id-abc123'
  
  return (
    <div className="login-button">
        <GoogleLogin
          clientId={CLIENT_ID}
          signinCallback={signin}
          errorCallback={error}
          options={options}
          className={className}
        />
      <div>{token}</div>
    </div>
  )
}

Properties

clientId (string)

The Client ID obtained from Google Cloud Console.

  1. Select the project
  2. Select APIs & Services
  3. Select Credentials
  4. Create an OAuth2 Client
  5. Copy the Client ID string
  6. Be sure to add all URL origins that will be using the Google Signin Button. Include http://localhost:PORT AND http://localhost

className

Class to be added to the Google button outside wrapper. To center the login button in a use the following CSS in the enclosing :

.login-button {
  height: 45px;
  width: fit-content;
  margin: 0 auto;
}

signinCallback

Signature: signinCallback(token: string) => void

Callback function fired with a successful login. The function receives one string parameter representing the JWT returned from the Google Authentication.

errorCallback

Signature: (err: any) => void

Error function is fired on a login error. The error object is passed as the only function parameter.

options

See full reference for GsiButtonConfiguration type

Button configuration options (see full documentation)

  • type: standard for full-size button or icon for a Google icon only (required)

  • theme: outline | filled_blue | filled_black

  • size: large | medium | small

  • text: signin_with | signup_with | continue_with | signup_with

  • shape: rectangular | pill | circle | square

  • logo_alignment: left | center

  • width: maximum width of the button

  • locale: for button localization