I have a simple form component that is expected to create a new user using the the ###firstName, ###lastName, ###username, and ###password from a react-hook-form application.
Is it possible to create this is user on the click of the form's submit button and have that user created on the appwrite account?
Sure, here is a code sample. Just an FYI I did not test this, it's just a concept of how you might accomplish this.
export default function LoginPage() {
const { register, handleSubmit, formState: { errors } } = useForm();
const onSubmit = (data) => {
try {
const user = await account.create(
ID.unique(),
data.email,
data.password,
data.name
);
const session = await account.createEmailPasswordSession(
data.email,
data.password
);
// navigate to app
} catch (err) {
console.error(err);
}
};
return (
<>
<p className="title">Registration Form</p>
<form onSubmit={handleSubmit(onSubmit)}>
<input type="text" {...register("name")} />
<input type="email" {...register("email")} />
<input type="password" {...register("password")} />
<input type={"submit"} />
</form>
</>
);
}
Recommended threads
- Cannot Send Email
for some reason i keep getting this error when i try to send a test email with appwrite messaging... "Failed sending to target MYEMAIL1234@gmail.com with error:...
- I/flutter (24410): AuthError: HandshakeE...
I/flutter (24410): AuthError: HandshakeException: Handshake error in client (OS Error: I/flutter (24410): TLSV1_ALERT_UNRECOGNIZED_NAME(tls_record.cc:592))
- Creating functions for FCM Token based M...
I have previously setup cloud run functions on my firebase project, which im looking to migrate to appwrite. I need help on getting started, and getting me thro...