Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.Summary
This hook allows for authenticating a user using email or sms OTP without the standard Dynamic SDK.How it works
TheuseConnectWithOtp hook exposes the connectWithEmail, connectWithSms and verifyOneTimePassword functions, with these functions you can send an OTP to a user and then verify the OTP code the user received.
The hook works with Dynamic User Verification provider.
| Method | Type | Description |
|---|---|---|
| connectWithEmail | (email: string, captchaToken?: string) => Promise | Sends the OTP to the provided email |
| connectWithSms | (phone: PhoneData, captchaToken?: string) => Promise | Sends the OTP to the provided phone |
| verifyOneTimePassword | (oneTimePassword: string) => Promise | Verify the provided OTP. The returned promise will be resolved if the OTP is valid or it will be rejected if the OTP is invalid |