Replies: 1 comment
-
I am actually quite interested in this. Is there anyone from the MSAL team that can elaborate more on this topic? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello team;
Since
msal-react
(&msal-browser
per extension) were designed primary for SPA, everything related to user authentication is happening in the browser.Today, as SSR is becoming a thing, and framework like NextJS or Remix are trendy, there is no doubt that we are going to see more and more applications using these kind of framework, and by extension, building them with an authentication / authorization framework like
msal-react
.Using
msal-react
today within a NextJS (or Remix) application works .... more or less.All the benefits from SSR is ... server side rendering.
But since, using
msal-react
, the layout of your page depends on the state of your user (authenticated, unauthenticated) and this state value is stored / resolved from the browser (localstorage
,sessionstorage
...),NextJS
can't render the page on the server.Basically, this piece of code can't be resolved on server side:
That means, the server will render everything that is not part of
<AuthenticatedTemplate>
or<UnauthenticatedTemplate>
and everything else it will be send to the browser to be resolved by the client.As example, this piece of code (part of the
<AuthenticatedTemplate>
children)will not be pre-render on server side, but will be sent as a json payload to be resolved on client side.
Frameworks like Next-auth are resolving the authentication on the server side, allowing SSR to be efficient.
I know we have
msal-node
that seems to handle the auth from the server side (I'm currently looking at this Hybrid sample) but is it something that could be on the roadmap formsal-react
?Beta Was this translation helpful? Give feedback.
All reactions