Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

734
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda