Back

SSR VS CSR Authentication

  • 0
  • Self Hosted
  • Auth
  • Web
sharif1410
4 Apr, 2024, 15:30

Hi, I am new to web development, so bear with me.

In Appwrite _init, server side Authentication was revealed. I don't understand the difference between SS login And CS login. What is the Pros and Cons of each one ? And which method is more secure ? Difference between having the authentication in a a cookie or in a JWT. And Which is best for a NextJS App. Thank you for your response.

TL;DR
- Developer is looking for guidance on SSR vs CSR authentication and when to use cookies or JSON Web Tokens. - CSR involves auth logic on the client side, while SSR involves backend logic. - CSR doesn't need backend, SSR offers more control with middleware. - Authentication in a cookie or JWT have pros and cons, depending on security needs. - A tutorial integrating server-side login with business logic is sought after. Solution: - Rely on SSR for more control over authentication. - Choose cookies for simple authentication needs, JWT for secure data transfer. - Consider using middleware for defining custom authentication logic. - Appwrite's SSR authentication example can provide
Binyamin
4 Apr, 2024, 15:37

First, In CSR all the auth logic happens on the client side, either mobile or web. In SSR all the logic happens in the backend.

So, in regular App deployment, there's no difference between the two, just the way you'll need to implement them.

Each one of the login logic has its benefits.

When using CSR you don't need to have **any ** backend and your app will work completely, meaning you'll be able to deploy an app using a mobile device or static file hosting, and Appwrite. No need for any other infrastructure.

When using SSR you get a huge benefit that you control the login with logic-middlewares and more. For example, if you want any user with @your-company.com email suffix when using the regular CSR login you won't be able to it, either everyone can register or no one. But, in SSR you're able to insert any logic in between,

sharif1410
4 Apr, 2024, 15:57

I see, thank you for your swift response! I have followed this example and all works well.

https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-1

But I wanted to know if there was a more mature tutorial or project, that integrate Server Side Login with middleware and some business-Logic.

sharif1410
4 Apr, 2024, 15:57

Also when should i use cookies and when should i use JSON Web Tokens ?

Binyamin
4 Apr, 2024, 16:10
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