Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

One-time Passcodes (OTP)

/

Login or create via SMS

Login or create via SMS


Method parameters


phone_number*string

Configurationobject

Additional configuration.

expiration_minutesint
localestring
enable_autofillboolean
autofill_session_duration_minutesnumber

Response fields


request_idstring

status_codeint

method_idstring
import React, { useCallback } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { useStytch } from '@stytch/react-native';

export const Login = () => {
  const stytch = useStytch();
  const sendPasscode = useCallback(() => {
    stytch.otps.sms.loginOrCreate('+12025550162', {
      expiration_minutes: 5,
      enable_autofill: true,
      autofill_session_duration_minutes: 30,
    });
  }, [stytch]);
  return (
    <View>
      <TouchableOpacity onPress={sendPasscode}>
        <Text>Send passcode</Text>
      </TouchableOpacity>
    </View>
  );
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "method_id": "phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0"
}