Skip to main content

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

The useConnectWithOtp 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.

Examples

Verify user with email OTP

This will display a field to input the email when the user is not authenticated or a field to verify the OTP code if the user is already authenticated. Once the OTP is verified, the Dynamic SDK will be authenticated and you can find the user object using the useDynamicContext hook.

Verify user with sms OTP

This will display three fields to input the phone data when the user is not authenticated: country iso code (e.g: ‘US’), country dial code (e.g. ‘1’) and phone number (e.g. ‘5555555555’) If user is already authenticated, it will display a field to verify the OTP code. Once the OTP is verified, the Dynamic SDK will be authenticated and you can find the user object using the useDynamicContext hook.
Last modified on June 25, 2026