Search code examples
recaptcharecaptcha-v3

google reCAPTCHA v3 bottomleft


Reading through the code at https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js there are numerous references to bottomleft (as opposed to bottomright where the icon is generally placed, I presume).

But how do I enable this setting and move the icon to the bottom left?


Solution

  • just worked this out. You need:

    window._grecaptcha_callback = () => {
      window.grecaptcha.render({
        sitekey: grecaptcha_key,
        badge: 'bottomleft',
      })
      window.grecaptcha.ready(() => {
        // grecaptcha is ready
      })
    }
    

    Then load the script as https://www.google.com/recaptcha/api.js?onload=_grecaptcha_callback.

    With this the way you call execute has to change slightly to simply

    window.grecaptcha.execute(0, {action})
    

    eg. 0 instead of the site key as the first argument.

    Looking through the code there are a number of other undocumented settings:

    sitekey, type, theme, size, tabindex, stoken, bind, preload, badge, s, pool, 'content-binding', action
    

    But apart fromt sitekey and badge I don't know what they do. But they probably correspond roughly to the settings for v2.