react-google-recaptcha-v3
react-google-recaptcha-v3 copied to clipboard
Is it possible to use recaptcha v2 as a fallback with this library?
Looks like a common use-case but isn't documented so opened this issue to segregate all the challenges that users face.
There could be different approaches for loading Recaptcha v2.
Approach 1 - Support in this library itself
Google's documentation mentions that the v3 script is able to load v2 as well. Can we enable that functionality within the react-google-recaptcha-v3
package so users can load v2 without having to use any other hacks?
https://developers.google.com/recaptcha/docs/faq#can-i-run-recaptcha-v2-and-v3-on-the-same-page
Approach 2 - Document how to completely remove this library from DOM
The most common approach I've seen of users trying to use a fallback is to use a completely different npm package for Recaptcha v2. Example: https://github.com/dozoisch/react-google-recaptcha
There are several issues with this.
- The scripts/objects added by this library aren't removed from DOM when we remove its Provider. Can it be documented how to completely unmount this library so the devs can use something else as a fallback? Related: https://github.com/t49tran/react-google-recaptcha-v3/issues/183
- executeRecaptcha isn't documented well. Devs usually want to trigger v2 in their apps if v3 gives a low score to their users. Can we provide a documentation/example for how to do that? Related: https://github.com/t49tran/react-google-recaptcha-v3/issues/69#issuecomment-819159385
- The most significant drawback with this approach is that we'll need to lazy load any fallback library, which isn't recommended by Google: https://developers.google.com/recaptcha/docs/loading#lazy_loading. We can't load another v2 recaptcha along with this one since both will modify the
window.grecaptcha
object so if we load both, we wouldn't know which version we end up executing.
Approach 3 - Recommend another library
If v2 usage is completely out of scope for this package, can we add a note in the readme to recommend another package that's meant to solve for that use-case? Example: https://github.com/antokara/react-recaptcha-x This would also close the related issues mentioned in approach 2 above, since a lot of users are following those issues because they want to use v2 recaptcha as a fallback for this package.
anything new with these interesting solutions?