Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): fix unstable_getServerSession arguments #4815

Merged
merged 2 commits into from Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/docs/getting-started/client.md
Expand Up @@ -427,13 +427,14 @@ This only works on pages where you provide the correct `pageProps`, however. Thi

```js title="pages/index.js"
import { unstable_getServerSession } from "next-auth/next"
import { authOptions } from './api/auth/[...nextauth]'

...

export async function getServerSideProps(ctx) {
export async function getServerSideProps({ req, res }) {
return {
props: {
session: await unstable_getServerSession(ctx)
session: await unstable_getServerSession(req, res, authOptions)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/docs/getting-started/example.md
Expand Up @@ -97,6 +97,7 @@ To protect an API Route, you can use the [`unstable_getServerSession()`](/config

```javascript title="pages/api/restricted.js" showLineNumbers
import { unstable_getServerSession } from "next-auth/next"
import { authOptions } from "./api/auth/[...nextauth]"

export default async (req, res) => {
const session = await unstable_getServerSession(req, res, authOptions)
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/tutorials/securing-pages-and-api-routes.md
Expand Up @@ -62,6 +62,7 @@ You need to add this to every server rendered page you want to protect. Be aware

```js title="pages/server-side-example.js"
import { useSession, unstable_getServerSession } from "next-auth/next"
import { authOptions } from "./api/auth/[...nextauth]"

export default function Page() {
const { data: session } = useSession()
Expand Down Expand Up @@ -120,6 +121,7 @@ You can protect API routes using the `unstable_getServerSession()` method.

```js title="pages/api/get-session-example.js"
import { unstable_getServerSession } from "next-auth/next"
import { authOptions } from "./api/auth/[...nextauth]"

export default async (req, res) => {
const session = await unstable_getServerSession(req, res, authOptions)
Expand Down