
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
- Appwrite Cloud + Firebase hosting login ...
Hey team, can you please add the following to the CORS allowlist for my cloud project? Project ID: 68633b67002faf66fbcf Domains to allow: - https://taggit-...
- Realtime Disconnects and Error: INVALID_...
Hi Support, we are still experiencing the issue and we are a subscriber on your platform under the account of charlesbcalague@gmail.com I just want to ask here...
- Collection Permission issue
I am facing issue in my Pro account. "Add" button is disabled while adding permission in DB collection settings.
