Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Passwords

/

Create

Create

The Create method wraps the Create Password API endpoint. If a user with this email already exists in the project, this API will return an error. Existing passwordless users who wish to create a password need to go through the reset password flow.

This endpoint will return an error if the password provided does not meet our strength requirements, which you can check beforehand with the Strength Check Password API endpoint.

If this method succeeds, the user will be logged in, granted an active session, and the session cookies will be minted and stored in the browser.


Method parameters


email*string

password*string

session_duration_minutes*int

Response fields


request_idstring

status_codeint

user_idstring

email_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 createPassword = useCallback(() => {
    stytch.passwords.create({
      email: '${exampleEmail}',
      password: 'q8Zs)L0t1Emx_I61',
      session_duration_minutes: 60,
    });
  }, [stytch]);

  return (
    <View>
      <TouchableOpacity onPress={createPassword}>
        <Text>Create 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",
    "email_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953"
}