
I want to redirect admin to admin page and others to user page, how can I do so?
TL;DR
Solution:
To redirect admins to the admin page and others to the user page based on their labels, you can modify the code as follows:
```ts
try {
const account = account.get();
if (account.labels.includes('admin')) {
redirect('admin');
} else {
redirect('dashboard');
}
} catch (err) {
redirect('sign-in');
}
```
After the user is authenticated you can check it's labels to see if they're an admin and if they are redirect them to whatever page you want.

you can do something like
TypeScript
// This is just something I created quickly so it probably won't work as is lol
try {
const account = account.get();
if(account.labels.includes('admin')) {
redirect('admin');
} else {
redirect('dashboard');
}
} catch (err) {
redirect('sign-in');
}
Recommended threads
- Sharing cookies
Hi, I’m using Appwrite Cloud, and I have a setup where my Appwrite backend is hosted on a subdomain (e.g., api.example.com), while my frontend (Next.js app) and...
- Organization not exists anymore
Hello! We have a problem with a cloud database. We are on the Free plan, but after a refresh the site wants me to create a new organisation, and I not see the c...
- JSON and Object Support in Collection do...
I am working with Next.Js and Appwrite Cloud, I am relatively New to Appwrite but i have noticed there is no direct support of JSON and Object support in attrib...
