0

tl;dr: move authentication from useAuth hook to the server side with laravel breeze with next.js?!

The situation

I am using a project setup like the original laravel breeze repo.

It ships with the useAuth hook, which handles the authentication on the client side.

This setup is barely satisfying as it does not utilize the server side rendering for all components that need authenticated content.

The Question

How could I provide a way to authenticate the user on the server side to gather all the information possible and render more on the server?

I don't need to get rid of useAuth at all.

My Attempt

I tried to move the hook getServerSideProps but that is not allowed. My knowledge of the useSWR used inside the useAuth is slightly thin.

malouan
  • 71
  • 5
  • Rather than moving the hook, which wouldn't work since `getServerSideProps` is not a React component/hook, try to extract the bits of logic that you need from it into server-side code. – juliomalves Oct 31 '22 at 23:55

0 Answers0