Closed urgent closed 2 years ago
Yes, this is possible with the serverSideProps
option in the page API: https://reverecre.github.io/relay-nextjs/docs/page-api#relayoptions.
Example usage would be something like:
export default withRelay(Home, HomeQuery, {
// ...
serverSideProps: async (context) => {
const { getSession } = await import('my-auth-library');
const session = await getSession(context);
return { session };
},
})
next-auth requires I pass a session prop from the server on page load. Otherwise there's a delay as a call is needed to be made client side. Is it possible to provide a server variable alongside relay-nextjs?