Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Passwords

/

Reset by Email

Reset by email

The resetByEmail method wraps the reset_by_email Password API endpoint.

If this method succeeds, the user will be logged in, granted an active session, and the session data will be persisted on device.

You can listen for successful login events anywhere in the codebase with the stytch.session.onChange() method or useStytchSession hook.


Method parameters


token*string

password*string

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

export const Login = ({ token }) => {
  const stytch = useStytch();

  const resetPassword = useCallback(async () => {
    if (token) {
      try {
        await stytch.passwords.resetByEmail({
          token: token,
          password: 'J^ACSIayCQJUZ#io',
          session_duration_minutes: 60,
        });
      } catch (error) {
        console.error('Password reset error:', error);
      }
    }
  }, [stytch, token]);

  return (
    <View>
      <TouchableOpacity onPress={resetPassword}>
        <Text>Reset Password</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"
  }