Back

Next.js 14 combination SSR and CSR

  • 0
  • Self Hosted
  • Web
dev_goran
19 Sep, 2024, 16:02

How I can reuse session from SSR because in client side I can not access to cookie. Can someone guide me for best practice, Thank you! I use server action to login and create session cookie const session = await login(email, password) if (session) { cookies().set(SESSION_COOKIE, session.secret, { path: '/', httpOnly: true, sameSite: 'lax', secure: true, }) and I want to use createJWT on client side to pass to my backend and use it for backend API calls

TL;DR
Developers seek guidance on reusing session from SSR in Next.js 14 mixing SSR and CSR. They are looking for best practices since the client side cannot access cookies directly. The solution involves creating a JWT on the client side to pass to the backend for API calls after setting the session cookie in the server.
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