marsidev / react-turnstile

Cloudflare Turnstile integration for React.
https://www.npmjs.com/package/@marsidev/react-turnstile
MIT License
414 stars 25 forks source link

feat: Add `getResponsePromise` #49

Closed marsidev closed 10 months ago

marsidev commented 10 months ago

This PR introduces a new method to get the token of the widget as a promise, it waits until the widget is rendered and solved. It has a timeout of 30000 ms.

It should fix #47

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-turnstile ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2024 6:24pm
zammitjohn commented 10 months ago

Looks good for my use case. I plan to call turnstileRef.current?.execute(), followed by getResponsePromise() in my handleSubmit function. Form is only submitted when promise is fulfilled.

Nice work!