Skip to content

Add Pages Router implementation #10528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions articles/quickstart/webapp/nextjs/01-login.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,23 @@ The `user` property contains sensitive information and artifacts related to the
The profile information is available through the `user` property exposed by the `getSession` function. Take this <a href="https://nextjs.org/docs/getting-started/react-essentials#server-components" target="_blank" rel="noreferrer">Server Component</a> as an example of how to use it:

```jsx
// Implementation for App Router
import { auth0 } from "@/lib/auth0";

export default async function ProfileServer() {
const { user } = await auth0.getSession();
return ( user && ( <div> <img src={user.picture} alt={user.name}/> <h2>{user.name}</h2> <p>{user.email}</p> </div> ) );
}
```

```jsx
// Implementation for Pages Router
import { auth0 } from "@/lib/auth0";

export default async function ProfileServer(req) {
const { user } = await auth0.getSession(req); // As you can see here, `getSession` required to receive the `req` object as parameter, only in Pages Router
return ( user && ( <div> <img src={user.picture} alt={user.name}/> <h2>{user.name}</h2> <p>{user.email}</p> </div> ) );
}
```

:::panel Checkpoint
Expand Down