Hi everyone,
I am trying to integrate Auth0 to my Next.JS app. Currently, my app always try to get data from my backend. Now, with this integration of Auth0, I am trying to get user specific data. I am looking at the examples on Github and it seems that while my user is being authenticated with withPageAuthRequired
in the getServerSideProps
computation, it cannot use the specific user to get user specific data on the server side. Is this correct?
Here are the example that I see on Github:
import { withPageAuthRequired } from '@auth0/nextjs-auth0';
export default function Profile({ user }) {
return <div>Hello {user.name}</div>;
}
// You can optionally pass your own `getServerSideProps` function into
// `withPageAuthRequired` and the props will be merged with the `user` prop
export const getServerSideProps = withPageAuthRequired();
I also tried passing an object with the getServerSideProps
field to withPageAuthRequired
and the parameter have the user as a field. Is this right? What is the justification for just being able to retrieve a user at the getServerSideProps
and not user dependent data.
The main reason why I started to use Next.JS is because I can have a lot of my data retrieved at the server rendering side, which makes my application more smoother and performant. It would be a waste to select Next.JS as a framework for my app if I can just get a user’s info when using getServerSideProps
.