What's the suggested way of sign-up/ login process and retrieving user data in latest NextJS?
- 0
- Web
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?
What's the suggested way of sign-up/ login process and retrieving user data in latest NextJS?
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?
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
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. π
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
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?.
I tried adding custom domain in appwrite with vercel subdomain and it did failed in validation.
This was the format I added: appwrite.myapp.vercel.app
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
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)
Thanks for this.. Will take a look π
Sorry Im a bit confused on this part. If I deployed on vercel, how can I add my custom domain in appwrite?
to be ensured, by "custom domain" you mean this, right?
Yeah that part. I dont need to add it in there manually?
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)
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
I see..Thanks @manazo ... Appreciate your help and reminder π
Hey @manazo , I just remember your project in progress. Are you using Cloud?
Hi. sorry i didn't notice the mention. yes i'm using cloud
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
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
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...