Best practice question
Unanswered
Oriental Scops-Owl posted this in #help-forum
Oriental Scops-OwlOP
Hi. I have a website i am working on and i am calling my backend from the front end for the user dashboard area.
Since this is a guarded area of the website that requires login, is it acceptable to call the backend from the browser?
trying to understand the best practice for when to use SSR versus web client
i assume if i wanted to render the page before page finishes loading for something like Google to crawl, then SSR is required.
this has always been my approach... currently im storing my user info/jwt in my local storage but working on moving it to http only cookie. the question then i have is how does the nextjs backend access the cookie or local storage? i was under the assumption you had to use something like redux to store it in backend
Since this is a guarded area of the website that requires login, is it acceptable to call the backend from the browser?
trying to understand the best practice for when to use SSR versus web client
i assume if i wanted to render the page before page finishes loading for something like Google to crawl, then SSR is required.
this has always been my approach... currently im storing my user info/jwt in my local storage but working on moving it to http only cookie. the question then i have is how does the nextjs backend access the cookie or local storage? i was under the assumption you had to use something like redux to store it in backend
5 Replies
Largehead hairtail
Hi @Oriental Scops-Owl ,
You can access cookies in server action or api route.
https://nextjs.org/docs/app/api-reference/functions/cookies
Notes:
You can't access redux in SSR, so you should use cookie at the first time, and then use redux
You can access cookies in server action or api route.
https://nextjs.org/docs/app/api-reference/functions/cookies
Notes:
You can't access redux in SSR, so you should use cookie at the first time, and then use redux
Oriental Scops-OwlOP
thanks. im still using the pages folder at the moment.. i should probably work on migrating over to app folder
is there any advantage over calling my API in the backend, versus front end ?
Largehead hairtail
I think calling from frontend is the better if there is not any speical requirements.
Oriental Scops-OwlOP
alright. so if i needed to prerender, then SSR it is. otherwise, guarded areas are fine for calling from frontend