()
| 2 | import Layout from "../components/layout" |
| 3 | |
| 4 | export 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 |
| 35 | export async function getServerSideProps(context) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…