
I'm using Appwrite to create an email session with users. At the moment, I do very basic checks within the login form component that check if the password is longer than 8 characters. I then call a function in a separate utility file that handles the login. How can I check for errors such as no user found? Is there perhaps a boilerplate for an appwrite login and register function that I can look at? I'm fairly new to React, is code within a component secure, i.e: can I call the createEmailSession
from the component file?

You can put it in the component. It's up to you how you want to organize your code.
To handle errors, wrap in try/catch, and then handle the exception

Hi @larkx , here is a pseudo example using try catch:
import { sdk } from 'appwrite';
const loginUser = async (email, password) => {
try {
await sdk.account.createEmailSession(email, password);
} catch (error) {
if (error.code === 'user-not-found' // any other error you are checking for) {
console.log('User not found. Please check your credentials.');
} else {
console.log('An error occurred:', error.message);
}
}
};```
Recommended threads
- what is the best way to redirect a prett...
I tried to do this in a function, but after redirecting to the bucket and try to play video, i get CORS error: The 'Access-Control-Allow-Origin' header has a va...
- Can't download a file through the AppWri...
Heya! SO I am learning backend using Node.js. I am using AppWrite for storage, and in the application I want the files to be downloaded, which are stored by the...
- Vite build permission failed
im trying to deploy a react site using appwrite sites and it keeps failing to build ```2025-08-10T20:20:15.168371867Z [20:20:15] [open-runtimes] Environment pr...
