You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/quickstart/webapp/nextjs/01-login.md
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -212,13 +212,23 @@ The `user` property contains sensitive information and artifacts related to the
212
212
The profile information is available through the `user` property exposed by the `getSession` function. Take this <ahref="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:
213
213
214
214
```jsx
215
+
// Implementation for App Router
215
216
import { auth0 } from"@/lib/auth0";
216
217
217
218
exportdefaultasyncfunctionProfileServer() {
218
219
const { user } =awaitauth0.getSession();
219
220
return ( user && ( <div><img src={user.picture} alt={user.name}/><h2>{user.name}</h2><p>{user.email}</p></div> ) );
220
221
}
222
+
```
223
+
224
+
```jsx
225
+
// Implementation for Pages Router
226
+
import { auth0 } from"@/lib/auth0";
221
227
228
+
exportdefaultasyncfunctionProfileServer(req) {
229
+
const { user } =awaitauth0.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> ) );
0 commit comments