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
- AttributeError: 'Context' object has no ...
I'm getting an error executing my function. I'm not able to replicate this locally since I have to use a mock context. Is there a way to debug this kind of erro...
- Support for adding domain...
I dont know how to setup domain on appwrite sites, need your help
- SSR share session to client using custom...
Hi, so I was trying to get a hang of using SSR and using realtime updates in the same time which is done easiest if you have a custom domain in Appwrite and as ...