Skip to content

Commit

Permalink
docs: clarify page protection (nextauthjs#2355)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnphpexpert committed Jul 11, 2021
1 parent 1a2ca77 commit d6c26b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions www/docs/getting-started/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export default function App({

If you pass the `session` page prop to the `<SessionProvider>` – as in the example above – you can avoid checking the session twice on pages that support both server and client side rendering.

This only works on pages where you provide the correct `pageProps`, however. This is normally done in `getInitialProps` or `getServerSideProps` like so:
This only works on pages where you provide the correct `pageProps`, however. This is normally done in `getInitialProps` or `getServerSideProps` on an individual page basis like so:

```js title="pages/index.js"
import { getSession } from "next-auth/react"
Expand All @@ -376,7 +376,7 @@ export async function getServerSideProps(ctx) {
}
```

If every one of your pages needs to be protected, you can do this in `_app`, otherwise you can do it on a page-by-page basis. Alternatively, you can do per page authentication checks client side, instead of having each authentication check be blocking (SSR) by using the method described below in [alternative client session handling](#custom-client-session-handling).
If every one of your pages needs to be protected, you can do this in `getInitialProps` in `_app`, otherwise you can do it on a page-by-page basis. Alternatively, you can do per page authentication checks client side, instead of having each authentication check be blocking (SSR) by using the method described below in [alternative client session handling](#custom-client-session-handling).

### Options

Expand Down

0 comments on commit d6c26b0

Please sign in to comment.