Back

What's the suggested way of sign-up/ login process and retrieving user data in latest NextJS?

  • 0
  • Web
Nikky
30 Aug, 2023, 04:32

Been trying to find a way how to do get user server side in Next. But found out SSR is not fully supported yet in Appwrite (Is this correct?). Would like to ask what's the suggested flow in using appwrite with NextJS? Flow and where to do it client/server? Also, in creating account, I need to store more user data -> what's the suggested way? Create function in appwrite? or call another function to store user data after successful signup?

TL;DR
User is asking for the suggested way to handle sign-up, login, and retrieving user data in the latest version of NextJS. There is no clear solution provided in the thread.
Nikky
30 Aug, 2023, 04:32

What's the suggested way of sign-up/ login process and retrieving user data in latest NextJS?

manazo
30 Aug, 2023, 06:28

Hey @Nikky . Welcome to the server. Can you please confirm what you're actually trying to achieve? Are you trying to get user data in a NextJS server component? or sign-up/login a user? or store additional data in a user account while creating?

Nikky
30 Aug, 2023, 06:33

Hey Pratik, thanks.. So basically all.

  • Signup - create account & store additional user info in DB
  • Login - login and get user data inside SSR component in NextJS
Nikky
30 Aug, 2023, 06:35

Im wondering what's the suggested way to do all of that in NextJs leveraging SSR. But I learned SSR is not yet supported? So I wonder what will be the suggested approach for now. πŸ™‚

manazo
30 Aug, 2023, 06:42

It's true that SSR is not yet fully supported in Appwrite. Currently, Appwrite uses the browser's localStorage to store session tokens, and that's the only client-side dependency we have now. So to overcome this, what we can do is hit the sign-up/login endpoint manually, get the returned session cookie, and store that as a server-side cookie using NextJS's cookie. However, while storing the cookie, you need to maintain some structure, so that Appwrite can work with those cookies later. You can check this repo for a better understanding

Nikky
30 Aug, 2023, 06:46

I actually have started following this repo this morning, but this also requires the app to be served in own domain, and set appwrite as subdomain? I'm using vercel subdomain and so this is not possible for me, is this correct?.

Nikky
30 Aug, 2023, 06:47

I tried adding custom domain in appwrite with vercel subdomain and it did failed in validation.

Nikky
30 Aug, 2023, 06:48

This was the format I added: appwrite.myapp.vercel.app

manazo
30 Aug, 2023, 06:51

No, it doesn't require the app to be served in a custom domain. You can check this repo of mine that I'm currently working on. My app is still in local development now. I'm using the Magic URL to sign-up/in the user and it works perfectly. I've followed the same workaround here

manazo
30 Aug, 2023, 06:53

Appwrite doesn't allow subdomains to be added as custom domains directly. You'll first need to add the main domain and then you can add subdomains of that (afaik)

Nikky
30 Aug, 2023, 06:59

Thanks for this.. Will take a look πŸ˜€

Nikky
30 Aug, 2023, 07:01

Sorry Im a bit confused on this part. If I deployed on vercel, how can I add my custom domain in appwrite?

manazo
30 Aug, 2023, 07:03

to be ensured, by "custom domain" you mean this, right?

Nikky
30 Aug, 2023, 07:06

Yeah that part. I dont need to add it in there manually?

manazo
30 Aug, 2023, 07:10

Depends on what you're actually trying to achieve. The above shown custom domain is for hosting the Appwrite console in your own domain. In that case, you need to add a main domain (i.e. example.com), verify the domain ownership, and stuff. But if you're trying to add your app's hostname as the trusted (sub)domain, you can add it here (below ss)

manazo
30 Aug, 2023, 07:26

Just a reminder: As the project is still under development, it might have future commits. The main algo won't change hopefully, but the file structure might change. So check with alert eyes

Nikky
31 Aug, 2023, 03:04

I see..Thanks @manazo ... Appreciate your help and reminder πŸ™

Nikky
5 Sep, 2023, 04:55

Hey @manazo , I just remember your project in progress. Are you using Cloud?

manazo
10 Sep, 2023, 17:53

Hi. sorry i didn't notice the mention. yes i'm using cloud

Nikky
12 Sep, 2023, 11:30

No worries. So I found out relationship is not supported yet in cloud. Do you have a use case for that? have you found a work around? @manazo

manazo
12 Sep, 2023, 18:27

No i don't have any use case of that in my current project. But afaik Appwrite Cloud is still in v1.1.2 and relationships are supported in the latest versions. so the only workaround i can think of is to self-host any latest version of Appwrite

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more