Back

Getting Next.js session using Serversideprops

  • 0
  • Self Hosted
  • Web
Danny
23 May, 2023, 21:17

Hi! Im attempting to get the users session using serversideprops to speed up the page load, how do i get the session using the req and res/serversideprops in Next.js?

TL;DR
Title: How to Get Next.js Session using ServerSideProps - Currently, executing Client SDK actions with a Server side SDK is not possible. - There is a feature request related to this issue; you can upvote it here: https://github.com/appwrite/appwrite/issues/3891 - Plans are being made to make this process easier in the near future. - For anonymous login, you can refer to the code provided by Meldiron in this Discord thread: https://discord.com/channels/564160730845151244/564160731327758347/1110645396620988436 - However,
Binyamin
23 May, 2023, 21:18

You can see a good example of Appwrite auth with nextjs in Meldiron project Almost SSR https://next-js.ssr.almostapps.eu/ https://github.com/Meldiron/appwrite-ssr-next-js

Danny
24 May, 2023, 16:57

I've looked at this code but it seems to be for anonymous login only, as the anonymous session is created server-side. How can i do this for oauth?

Binyamin
24 May, 2023, 17:00

Yes in this type of login it can be a bit tricky, check Meldiron advice here. https://discord.com/channels/564160730845151244/564160731327758347/1110645396620988436

Danny
24 May, 2023, 17:05

and are there any plans to make this process easier in the near future?

Binyamin
24 May, 2023, 17:06

I think. but not in the very near future. You can see this feature request is related to the core logic of the issue, you can upvote this. https://github.com/appwrite/appwrite/issues/3891

Binyamin
24 May, 2023, 17:07

Because as of now there is no way to execute Client SDK actions with a Server side SDK.

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