You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/sdks/nextjs-sdk/README.md
+14-1
Original file line number
Diff line number
Diff line change
@@ -200,7 +200,7 @@ This setup ensures that you can clearly define which routes in your application
200
200
201
201
use the `session()` helper to read session information in Server Components and Route handlers.
202
202
203
-
Note: `session()` requires the `authMiddleware`to be used for the Server Component or Route handler that uses it.
203
+
Note: While using `authMiddleware` is still recommended for session management (because it validates the session only once), `session()` can function without it. If `authMiddleware`does not set a session, `session()` will attempt to retrieve the session token from cookies, then parse and validate it.
204
204
205
205
Server Component:
206
206
@@ -234,6 +234,19 @@ export async function GET() {
234
234
}
235
235
```
236
236
237
+
##### Optional Parameters
238
+
239
+
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.
240
+
241
+
```
242
+
session({ projectId?: string, baseUrl?: string })
243
+
```
244
+
245
+
-**projectId:** The Descope Project ID. If not provided, the function will fall back to `DESCOPE_PROJECT_ID` from the environment variables.
246
+
-**baseUrl:** The Descope API base URL.
247
+
248
+
This allows developers to use `session()` even if the project ID is not set in the environment.
249
+
237
250
#### Access Descope SDK in server side
238
251
239
252
Use `createSdk` function to create Descope SDK in server side.
0 commit comments