Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Users

/

Delete authentication factors

Delete authentication factors

Wraps Stytch's delete authentication factors family of endpoints and can be used to remove factors from a user.

These methods cannot be used to remove all factors from a user. A user must have at least one email, phone number, or OAuth provider associated with their account at all times, otherwise they will not be able to log in again.

You can listen for successful user updates anywhere in the codebase with the stytch.user.onChange() method or useStytchUser() hook.

Note: If a user has enrolled another MFA method, this method will require MFA. See the Multi-factor authentication section for more details.


Method parameters


method_id*string
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 deleteEmail = useCallback(() => {
    stytch.user.deleteEmail('email-test-81bf03a8-86e1-4d95-bd44-bb3495224953');
  }, [stytch]);

  const deletePhoneNumber = useCallback(() => {
    stytch.user.deletePhoneNumber('phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0');
  }, [stytch]);

  const deleteWebauthnRegistration = useCallback(() => {
    stytch.user.deleteWebauthnRegistration('webauthn-registration-test-5c44cc6a-8af7-48d6-8da7-ea821342f5a6');
  }, [stytch]);

  return (
    <>
      <View>
        <TouchableOpacity onPress={deleteEmail}>
          <Text>Delete email</Text>
        </TouchableOpacity>
      </View>

      <View>
        <TouchableOpacity onPress={deletePhoneNumber}>
          <Text>Delete phone number</Text>
        </TouchableOpacity>
      </View>

      <View>
        <TouchableOpacity onPress={deleteWebauthnRegistration}>
          <Text>Delete WebAuthn registration</Text>
        </TouchableOpacity>
      </View>
    </>
  );
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
  "user": {...}
}