Skip to content

Commit eab260c

Browse files
authored
Add Pages Router implementation
1 parent a27ab75 commit eab260c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

articles/quickstart/webapp/nextjs/01-login.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,23 @@ The `user` property contains sensitive information and artifacts related to the
212212
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:
213213

214214
```jsx
215+
// Implementation for App Router
215216
import { auth0 } from "@/lib/auth0";
216217

217218
export default async function ProfileServer() {
218219
const { user } = await auth0.getSession();
219220
return ( user && ( <div> <img src={user.picture} alt={user.name}/> <h2>{user.name}</h2> <p>{user.email}</p> </div> ) );
220221
}
222+
```
223+
224+
```jsx
225+
// Implementation for Pages Router
226+
import { auth0 } from "@/lib/auth0";
221227

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

224234
:::panel Checkpoint

0 commit comments

Comments
 (0)