Sometimes you build yourself a web application. You have the frontend and the backend. You don’t want other people to be able to access your backend, so you must protect it somehow.

This library provides a simple way to protect your backend with Google Sign-In.

This library is a thin wrapper on top of Google Sign-In. It takes care of asynchronously loading the Google Platform Library and the Google Sign-In JavaScript API, and provides simple hooks to access the user ID token.

Set up

To create an OAuth 2.0 Client ID:

  1. Click on Create Credentials  OAuth Client ID.

  2. Select Application type  Web application.

  3. Enter a name for the application.

  4. In the Authorized JavaScript origins field, add an origin.

  5. Click Create

  6. Note the Client ID.


export const signInController = new GoogleSignInController(clientId)

For usage see API documentation.