The problem
A new version of Next.js was released recently: https://nextjs.org/blog/next-13
It introduces several new concepts and ways of writing Next.js apps with sever-components in mind. In this new release, the data fetching operations are supposed to happen in pages or layouts.
This introduces a new way of addressing auth state in the whole app. We can finally have the auth state in the global layout.tsx and share it across all the pages of the app.
Yet, this library currently sets the auth state on the server side through getServerSideProps and withAuthUserTokenSSR. As far as I understand, the new approach gets rid of the getServerSideProps, getStaticProps, and getInitialProps making the current authentication approach incompatible.
Describe the solution you'd like and how you'd implement it
I'm not sure about the implementation, to be honest. Yet, I'd love to have a way of accessing the auth state on the server.
My biggest use case would be to have the auth state inside the global layout: app/layout.tsx.
This will enable us to share the auth state across the whole app and not have export const getServerSideProps = withAuthUserTokenSSR() statements on several pages.
As an implementation detail, I think the pages/api/login.ts and pages/api/logout.ts should probably stay unchanged as the docs state that pages/api/* should remain unchanged: https://beta.nextjs.org/docs/upgrade-guide#migrating-from-pages-to-app
Is this a breaking change?
I think yes it's probably a breaking change.
The problem
A new version of Next.js was released recently: https://nextjs.org/blog/next-13
It introduces several new concepts and ways of writing Next.js apps with sever-components in mind. In this new release, the data fetching operations are supposed to happen in
pagesorlayouts.This introduces a new way of addressing auth state in the whole app. We can finally have the auth state in the global
layout.tsxand share it across all the pages of the app.Yet, this library currently sets the auth state on the server side through
getServerSidePropsandwithAuthUserTokenSSR. As far as I understand, the new approach gets rid of thegetServerSideProps,getStaticProps, andgetInitialPropsmaking the current authentication approach incompatible.Describe the solution you'd like and how you'd implement it
I'm not sure about the implementation, to be honest. Yet, I'd love to have a way of accessing the auth state on the server.
My biggest use case would be to have the auth state inside the global layout:
app/layout.tsx.This will enable us to share the auth state across the whole app and not have
export const getServerSideProps = withAuthUserTokenSSR()statements on several pages.As an implementation detail, I think the
pages/api/login.tsandpages/api/logout.tsshould probably stay unchanged as the docs state thatpages/api/*should remain unchanged: https://beta.nextjs.org/docs/upgrade-guide#migrating-from-pages-to-appIs this a breaking change?
I think yes it's probably a breaking change.