Skip to content

Commit dacfd9e

Browse files
committed
fix: next.js readme
1 parent 6fe110c commit dacfd9e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

packages/sdks/nextjs-sdk/README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Descope SDK for NextJS
1+
# Descope SDK for Next.js
22

3-
The Descope SDK for NextJS provides convenient access to the Descope for an application written on top of NextJS. You can read more on the [Descope Website](https://descope.com).
3+
The Descope SDK for Next.js provides convenient access to the Descope for an application written on top of Next.js. You can read more on the [Descope Website](https://descope.com).
44

55
This SDK uses under the hood the Descope React SDK and Descope Node SDK
66
Refer to the [Descope React SDK](https://github.com/descope/descope-js/tree/main/packages/sdks/react-sdk) and [Descope Node SDK](https://github.com/descope/node-sdk) for more details.
77

88
## Requirements
99

10-
- The SDK supports NextJS version 13 and above.
10+
- The SDK supports Next.js version 13 and above.
1111
- A Descope `Project ID` is required for using the SDK. Find it on the [project page in the Descope Console](https://app.descope.com/settings/project).
1212

1313
## Installing the SDK
@@ -131,7 +131,7 @@ const App = () => {
131131

132132
##### Require authentication for application (Middleware)
133133

134-
You can use NextJS Middleware to require authentication for a page/route or a group of pages/routes.
134+
You can use Next.js Middleware to require authentication for a page/route or a group of pages/routes.
135135

136136
Descope SDK provides a middleware function that can be used to require authentication for a page/route or a group of pages/routes.
137137

@@ -229,7 +229,7 @@ Route handler:
229229
// src/pages/api/routes.ts
230230
export async function GET() {
231231
const currSession = await session();
232-
if (!currSession.isAuthenticated) {
232+
if (!currSession) {
233233
// ...
234234
}
235235

@@ -238,6 +238,18 @@ export async function GET() {
238238
}
239239
```
240240

241+
The `session()` function uses Next.js's `cookies()` and `headers()` functions to retrieve the session token. If you are using Next.js Version 13, you can use the `getSession(req)` instead.
242+
243+
```js
244+
import { getSession } from '@descope/nextjs-sdk/server';
245+
246+
export async function GET(req) {
247+
const currSession = await getSession(req);
248+
249+
// ...
250+
}
251+
```
252+
241253
##### Optional Parameters
242254

243255
If the middleware did not set a session, The `session()` function will attempt to retrieve the session token from cookies and validates it, this requires the project ID to be either set in the environment variables or passed as a parameter to the function.

0 commit comments

Comments
 (0)