Here's how you do auth with 100% SSR in Next.js

preview_player
Показать описание
Integrate Appwrite with NEXT.js with app router, server rendered components, and server actions. Build protected pages & API routes with user sessions.

💬 Follow Appwrite on social media & join our Discord community.

Time stamps:

00:00 Intro
3:00 App setup
9:07 Connecting Appwrite
12:40 Creating admin client
15:50 API route (W/Admin Client)
18:00 Querying data with SSR components
21:23 Protected pages
25:02 Creating session client
26:15 Session client requests
28:45 Creating & setting sessions
35:56 Getting user
39:30 Manually sending cookies
45:34 Custom Fetch wrapper
49:28 Customer layouts (route groups)
53:40 Logout
Рекомендации по теме
Комментарии
Автор

Please also make a video on doing oauth with appwrite in nextjs😊

AjaySingh-jzqx
Автор

This was AMAZING Dennis 🎉
I really needed this!
You really should do a full course building a SaaS or similar with Appwrite and NextJS. Would gladly pay for that kind of material.

madsklitgaard
Автор

Thanks, Definitely needed this!!!
Been using Appwrite for every projects!
Need an OAuth in NextJS

woahdudecalmdown
Автор

Appreciate the hard work you put in to these videos Dennis! Lets go Appwrite!!

whitenoisewhale
Автор

Thanks for this Dennis! <3

Great to hear some more videos coming for SSR! It's where I'm at. If would be great to see how we can use authorize the client from the session cookie so we can use realtime! That's where I'm currently gearing towards in my new project.

Couple of things to advise:

- NEXT_PUBLIC_API_KEY = will be public! better just for APPWRITE_API_KEY or similar
- You can just do direct sessionClient database requests without setting up an api endpoint, the beauty of async server components if people wanted
- Layout files are not a good idea for checking sessions, (I found out recently) - middleware the recommended approach

JonLeeSmith
Автор

Def went with the right thumbnail :) Top was the way to go

JonLeeSmith
Автор

great work, wondering how setting and getting cookies would work with OAuth since OAuth is setting 3-4 cookies when user is logged in?

sikandarchishty
Автор

Sir why you are not uploading the subscription api using nodejs and lemon squeeze which you talked about previously
We are waiting for that🙏

Superuser-ry
Автор

I tried to implement this on my project with typescript but it seems not to work, it is throwing much errors related to server actions

JeandeDieuHAGENIMANA-gf
Автор

I'm experiencing weird behaviour with my middleware when i login using oAuth2. A session is created and the user is redirected to the /account route (the session is logged out in console). In my middleware file, the session does't exist and i'm given a "No Session" error (even when there is a session). Consequently the user is immediately redirected back to /login. This is only happening with oAuth2, my email authentication works fine. Any ideas why this could be happening?

NuttyLlamasftw
Автор

How we can make validation ?
I don't get it.

We should to prepare endpoints in our api or sth?

seveto
Автор

Thanks for the video!

I have a question. Is there a good way to use the session cookie on the client side too? I set the cookie after login using the "cookies-next" library so that it is also available on the client.
This only works if I remove the "httpOnly" flag in the setCookie function.

I guess there is a security issue with removing this, am I right? Do you have any other solutions?

renecouturier
Автор

I want one feature include that is join other tables like sql

nawabulhaq
Автор

i there an video to do the same auth operations like login logout too in client side appwrite at Account level ?

deadlylive_gaming
Автор

Would love to see a similar video with JWT token authentication with refresh token. Have always struggled with this topic

dmsnm
Автор

lack of isomorphic sdk is always a negative in javascript frameworks

hakuna_matata_hakuna
Автор

Nice video!
Doesn't NEXT_PUBLIC_API_KEY make the api key publicly accessible?

Suresh-brzz
Автор

❤ we love your work!. Is it possible to manage the state in ssr??

innovafrique
Автор

How to show a loading indicator when you are waiting the server response on login?

innovafrique
Автор

Why you use NEXT_PUBLIC in server side ?

seveto