Unlike withPageAuthRequired
, when using withMiddlewareAuthRequired
it is not clear how to pass our user data through to our app’s pageProps
, as there is no easy way to pass data from middleware to our app.
Meaning that we must either:
A) Fetch our user twice, once in our middleware and again in getServerSideProps.
B) Accept that there will be a slight delay before useUser
runs on the client.
Is there any best practice for this. How are people loading in their users from middleware and passing them into their app?