MCPcopy
hub / github.com/nextauthjs/next-auth / Page

Function Page

app/pages/server.js:4–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import Layout from "../components/layout"
3
4export default function Page() {
5 // As this page uses Server Side Rendering, the `session` will be already
6 // populated on render without needing to go through a loading stage.
7 // This is possible because of the shared context configured in `_app.js` that
8 // is used by `useSession()`.
9
10 return (
11 <Layout>
12 <h1>Server Side Rendering</h1>
13 <p>
14 This page uses the universal <strong>getSession()</strong> method in{" "}
15 <strong>getServerSideProps()</strong>.
16 </p>
17 <p>
18 Using <strong>getSession()</strong> in{" "}
19 <strong>getServerSideProps()</strong> is the recommended approach if you
20 need to support Server Side Rendering with authentication.
21 </p>
22 <p>
23 The advantage of Server Side Rendering is this page does not require
24 client side JavaScript.
25 </p>
26 <p>
27 The disadvantage of Server Side Rendering is that this page is slower to
28 render.
29 </p>
30 </Layout>
31 )
32}
33
34// Export the `session` prop to use sessions with Server Side Rendering
35export async function getServerSideProps(context) {

Callers

nothing calls this directly

Calls 2

getSessionFunction · 0.90
getServerSidePropsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…