Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

725
Views
How to use your own REACT button with google's Sign in with google library CDN

Google currently is discontiuing their old "sign in with google" and I am now using their new stuff which I followed by this guide on their documentation https://developers.google.com/identity/gsi/web/reference/js-reference

so in order to render their button you need to do this

import their cdn in public index.html

<script src="https://accounts.google.com/gsi/client"></script>

Then you should call it like this with React

  useEffect(() => {
  google.accounts.id.initialize({
      client_id: 'YOUR_GOOGLE_CLIENT_ID',
      callback: handleCredentialResponse
    });
   google.accounts.id.renderButton(document.getElementById('google-login-button'), {
      theme: 'outline',
      size: 'large',
    });
  }, []);

and then render the button out on a div like so (and no you can stand on your head with CSS and try all the palor tricks to target this div it will apply certain styling but then the switch to this other button happens and you cant style that at all)

  <div id="google-login-button" className="customGPlusSignIn" />

then it displays this button

enter image description here

so if you want to make change to it you need to style it with this

   google.accounts.id.renderButton(document.getElementById('google-login-button'), {
      theme: 'outline',
      size: 'large',
    });

BUT here comes the annoying part - it jumps from the above PRE styled button to enter image description here

(in this picture its bigger than the actual one, the actual one is WAAAY smaller than the first one it switches from)

And you can stand on your head with CSS and pull out all the tricks under the hood to make it stay the same size but it doesn't. IT ALWAYS STICKS TO THIS STYLING.

I really want to use my own button and I cant find a way to set the google.accounts.id.initialize({ to work with my own button.

do any of you have any idea how I can achieve WITHOUT USING A NPM package and staying vanilla google CDN (Reason why I DONT want to use an NPM package is because the NPM packages out there are using the OLD sign in with google api calls and its going to get depreciated next year March 30th (March 30th 2023)

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!