how to load external js like recaptcha without getting hydration error? #8322
-
Hi, { isHydrated ? <script src="https://www.google.com/recaptcha/api.js?render=<key>" async></script> : null} still doesnt work, does anyone figure it out? |
Beta Was this translation helpful? Give feedback.
Answered by
gustavopch
Dec 19, 2023
Replies: 2 comments 2 replies
-
anyone? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Try with this in your root.tsx: useEffect(() => {
const script = document.createElement('script')
script.async = true
script.src = `https://www.google.com/recaptcha/api.js?render=${key}`
document.head.appendChild(script)
}, []) It will run after hydration and prevent a mismatch between the server and client markup. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tomer-yechiel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try with this in your root.tsx:
It will run after hydration and prevent a mismatch between the server and client markup.