Skip to content

Commit d047fcb

Browse files
committed
small fixes
1 parent ba5f508 commit d047fcb

20 files changed

+75
-65
lines changed

v2/emailpassword/nextjs/app-directory/protecting-route.mdx

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ export const HomeClientComponent = () => {
3333
}
3434
```
3535

36-
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page.
36+
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page. It also does session claim checking on the frontend and take appropriate action if the claim validators fail. For example, if you have set the email verification recipe to be `"REQUIRED"`, and the user's email is not verified, this component will redirect the user to the email verification page.
3737

3838
:::caution
39-
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
39+
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. On the server side, this component renders an empty screen.
40+
41+
Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
4042
:::
4143

4244
### Using `useSessionContext`
@@ -108,7 +110,7 @@ This is a client component that renders just its children on the server side and
108110

109111
#### Creating the `TryRefreshComponent`
110112

111-
This component will refres hthe user's session if their current session has expired.
113+
This component will refresh the user's session if their current session has expired.
112114

113115
```tsx title="app/components/tryRefreshClientComponent.tsx"
114116
"use client";

v2/emailpassword/nextjs/app-directory/session-helpers.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ export async function withSession(
156156
```
157157

158158
- `getSSRSession` will be used in our frontend routes to get session information when rendering on the server side. This function will:
159-
- `{..., session: Object, hasToken: true}` is a session exists
159+
- `{..., session: Object, hasToken: true}` if a session exists
160160
- `{..., session: undefined, hasToken: false}` if a session does not exist
161-
- `{..., session: undefined, hasToken: true}` if the session is expired
162-
- `{..., session: undefined, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
161+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: false}` if the session is expired
162+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
163163

164164
- `withSession` will be used as a session guard for each of our API routes. If a session exists it will be passed to the callback, which is where we will write our API logic. If no session exists it will pass `undefined` to the callback. This function will:
165165
- Return status `401` if the session has expired

v2/emailpassword/nextjs/app-directory/session-verification-middleware.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This method is an alternative method for using sessions in an API. If you are al
1717

1818
In the middleware we check if a session exists using the `withSession` helper function we created [here](./session-helpers.mdx) and set the user's user id to the request headers using the session object. You can set other information in the same way.
1919

20-
:::note
20+
:::caution
2121
You cannot pass the full session container through the middleware because the Next.js middleware does not allow objects to be passed. If you need to access the full session container in your APIs switch to using [session guards](./session-verification-session-guard.mdx).
2222
:::
2323

@@ -65,9 +65,9 @@ export const config = {
6565
}
6666
```
6767

68-
## Using the middleware in APIs
68+
## Fetching the user ID in your APIs
6969

70-
The middleware will run for all our routes, we can read information set by the middleware in our API routes:
70+
The middleware will run for all routes, we can read information set by the middleware in the API routes:
7171

7272
```tsx title="app/api/userid/route.ts"
7373
import { NextResponse, NextRequest } from "next/server";

v2/emailpassword/nextjs/app-directory/session-verification-session-guard.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
id: session-verification-session-guard
3-
title: Adding a session guard to all API routes
3+
title: Adding a session guard to each API route
44
hide_title: true
55
---
66

77
<!-- COPY DOCS -->
88
<!-- ./thirdpartyemailpassword/nextjs/app-directory/session-verification-session-guard.mdx -->
99

10-
# Adding a session guard to all API routes
10+
# Adding a session guard to each API route
1111

1212
:::note
1313
This is applicable for when the frontend calls an API in the `/app/api` folder.
@@ -46,5 +46,5 @@ export function GET(request: NextRequest) {
4646
In the above snippet we are creating a `GET` handler for the `/api/user` route. We call the `withSession` helper function we created in a [previous step](./session-helpers.mdx), the function will pass the session object in the callback which we then use to read user information. If a session does not exist `undefined` will be passed intead.
4747

4848
The `withSession` guard will return:
49-
- Status `401` if the session does not exist or has expired
50-
- Stauts `403` if the session claims fail their validation. For example if email verification is required but the user's email is not verified.
49+
- Status `401` if the session does not exist or has expired
50+
- Stauts `403` if the session claims fail their validation. For example if email verification is required but the user's email is not verified.

v2/passwordless/nextjs/app-directory/protecting-route.mdx

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ export const HomeClientComponent = () => {
3333
}
3434
```
3535

36-
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page.
36+
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page. It also does session claim checking on the frontend and take appropriate action if the claim validators fail. For example, if you have set the email verification recipe to be `"REQUIRED"`, and the user's email is not verified, this component will redirect the user to the email verification page.
3737

3838
:::caution
39-
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
39+
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. On the server side, this component renders an empty screen.
40+
41+
Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
4042
:::
4143

4244
### Using `useSessionContext`
@@ -108,7 +110,7 @@ This is a client component that renders just its children on the server side and
108110

109111
#### Creating the `TryRefreshComponent`
110112

111-
This component will refres hthe user's session if their current session has expired.
113+
This component will refresh the user's session if their current session has expired.
112114

113115
```tsx title="app/components/tryRefreshClientComponent.tsx"
114116
"use client";

v2/passwordless/nextjs/app-directory/session-helpers.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ export async function withSession(
156156
```
157157

158158
- `getSSRSession` will be used in our frontend routes to get session information when rendering on the server side. This function will:
159-
- `{..., session: Object, hasToken: true}` is a session exists
159+
- `{..., session: Object, hasToken: true}` if a session exists
160160
- `{..., session: undefined, hasToken: false}` if a session does not exist
161-
- `{..., session: undefined, hasToken: true}` if the session is expired
162-
- `{..., session: undefined, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
161+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: false}` if the session is expired
162+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
163163

164164
- `withSession` will be used as a session guard for each of our API routes. If a session exists it will be passed to the callback, which is where we will write our API logic. If no session exists it will pass `undefined` to the callback. This function will:
165165
- Return status `401` if the session has expired

v2/passwordless/nextjs/app-directory/session-verification-middleware.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This method is an alternative method for using sessions in an API. If you are al
1717

1818
In the middleware we check if a session exists using the `withSession` helper function we created [here](./session-helpers.mdx) and set the user's user id to the request headers using the session object. You can set other information in the same way.
1919

20-
:::note
20+
:::caution
2121
You cannot pass the full session container through the middleware because the Next.js middleware does not allow objects to be passed. If you need to access the full session container in your APIs switch to using [session guards](./session-verification-session-guard.mdx).
2222
:::
2323

@@ -65,9 +65,9 @@ export const config = {
6565
}
6666
```
6767

68-
## Using the middleware in APIs
68+
## Fetching the user ID in your APIs
6969

70-
The middleware will run for all our routes, we can read information set by the middleware in our API routes:
70+
The middleware will run for all routes, we can read information set by the middleware in the API routes:
7171

7272
```tsx title="app/api/userid/route.ts"
7373
import { NextResponse, NextRequest } from "next/server";

v2/passwordless/nextjs/app-directory/session-verification-session-guard.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
id: session-verification-session-guard
3-
title: Adding a session guard to all API routes
3+
title: Adding a session guard to each API route
44
hide_title: true
55
---
66

77
<!-- COPY DOCS -->
88
<!-- ./thirdpartyemailpassword/nextjs/app-directory/session-verification-session-guard.mdx -->
99

10-
# Adding a session guard to all API routes
10+
# Adding a session guard to each API route
1111

1212
:::note
1313
This is applicable for when the frontend calls an API in the `/app/api` folder.
@@ -46,5 +46,5 @@ export function GET(request: NextRequest) {
4646
In the above snippet we are creating a `GET` handler for the `/api/user` route. We call the `withSession` helper function we created in a [previous step](./session-helpers.mdx), the function will pass the session object in the callback which we then use to read user information. If a session does not exist `undefined` will be passed intead.
4747

4848
The `withSession` guard will return:
49-
- Status `401` if the session does not exist or has expired
50-
- Stauts `403` if the session claims fail their validation. For example if email verification is required but the user's email is not verified.
49+
- Status `401` if the session does not exist or has expired
50+
- Stauts `403` if the session claims fail their validation. For example if email verification is required but the user's email is not verified.

v2/thirdparty/nextjs/app-directory/protecting-route.mdx

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ export const HomeClientComponent = () => {
3333
}
3434
```
3535

36-
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page.
36+
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page. It also does session claim checking on the frontend and take appropriate action if the claim validators fail. For example, if you have set the email verification recipe to be `"REQUIRED"`, and the user's email is not verified, this component will redirect the user to the email verification page.
3737

3838
:::caution
39-
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
39+
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. On the server side, this component renders an empty screen.
40+
41+
Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
4042
:::
4143

4244
### Using `useSessionContext`
@@ -108,7 +110,7 @@ This is a client component that renders just its children on the server side and
108110

109111
#### Creating the `TryRefreshComponent`
110112

111-
This component will refres hthe user's session if their current session has expired.
113+
This component will refresh the user's session if their current session has expired.
112114

113115
```tsx title="app/components/tryRefreshClientComponent.tsx"
114116
"use client";

v2/thirdparty/nextjs/app-directory/session-helpers.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ export async function withSession(
156156
```
157157

158158
- `getSSRSession` will be used in our frontend routes to get session information when rendering on the server side. This function will:
159-
- `{..., session: Object, hasToken: true}` is a session exists
159+
- `{..., session: Object, hasToken: true}` if a session exists
160160
- `{..., session: undefined, hasToken: false}` if a session does not exist
161-
- `{..., session: undefined, hasToken: true}` if the session is expired
162-
- `{..., session: undefined, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
161+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: false}` if the session is expired
162+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
163163

164164
- `withSession` will be used as a session guard for each of our API routes. If a session exists it will be passed to the callback, which is where we will write our API logic. If no session exists it will pass `undefined` to the callback. This function will:
165165
- Return status `401` if the session has expired

v2/thirdparty/nextjs/app-directory/session-verification-middleware.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This method is an alternative method for using sessions in an API. If you are al
1717

1818
In the middleware we check if a session exists using the `withSession` helper function we created [here](./session-helpers.mdx) and set the user's user id to the request headers using the session object. You can set other information in the same way.
1919

20-
:::note
20+
:::caution
2121
You cannot pass the full session container through the middleware because the Next.js middleware does not allow objects to be passed. If you need to access the full session container in your APIs switch to using [session guards](./session-verification-session-guard.mdx).
2222
:::
2323

@@ -65,9 +65,9 @@ export const config = {
6565
}
6666
```
6767

68-
## Using the middleware in APIs
68+
## Fetching the user ID in your APIs
6969

70-
The middleware will run for all our routes, we can read information set by the middleware in our API routes:
70+
The middleware will run for all routes, we can read information set by the middleware in the API routes:
7171

7272
```tsx title="app/api/userid/route.ts"
7373
import { NextResponse, NextRequest } from "next/server";

v2/thirdparty/nextjs/app-directory/session-verification-session-guard.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
id: session-verification-session-guard
3-
title: Adding a session guard to all API routes
3+
title: Adding a session guard to each API route
44
hide_title: true
55
---
66

77
<!-- COPY DOCS -->
88
<!-- ./thirdpartyemailpassword/nextjs/app-directory/session-verification-session-guard.mdx -->
99

10-
# Adding a session guard to all API routes
10+
# Adding a session guard to each API route
1111

1212
:::note
1313
This is applicable for when the frontend calls an API in the `/app/api` folder.
@@ -46,5 +46,5 @@ export function GET(request: NextRequest) {
4646
In the above snippet we are creating a `GET` handler for the `/api/user` route. We call the `withSession` helper function we created in a [previous step](./session-helpers.mdx), the function will pass the session object in the callback which we then use to read user information. If a session does not exist `undefined` will be passed intead.
4747

4848
The `withSession` guard will return:
49-
- Status `401` if the session does not exist or has expired
50-
- Stauts `403` if the session claims fail their validation. For example if email verification is required but the user's email is not verified.
49+
- Status `401` if the session does not exist or has expired
50+
- Stauts `403` if the session claims fail their validation. For example if email verification is required but the user's email is not verified.

v2/thirdpartyemailpassword/nextjs/app-directory/protecting-route.mdx

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ export const HomeClientComponent = () => {
3333
}
3434
```
3535

36-
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page.
36+
`SessionAuth` is a component exposed by the SuperTokens React SDK, it checks if a session exists and if it does not exist it will redirect the user to the login page. It also does session claim checking on the frontend and take appropriate action if the claim validators fail. For example, if you have set the email verification recipe to be `"REQUIRED"`, and the user's email is not verified, this component will redirect the user to the email verification page.
3737

3838
:::caution
39-
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
39+
At the moment the `SessionAuth` component does not support server side rendering and will only work on the client side. On the server side, this component renders an empty screen.
40+
41+
Refer to the <a href="#sessions-with-server-components">next section</a> of this page to learn how to use sessions on the server side.
4042
:::
4143

4244
### Using `useSessionContext`
@@ -108,7 +110,7 @@ This is a client component that renders just its children on the server side and
108110

109111
#### Creating the `TryRefreshComponent`
110112

111-
This component will refres hthe user's session if their current session has expired.
113+
This component will refresh the user's session if their current session has expired.
112114

113115
```tsx title="app/components/tryRefreshClientComponent.tsx"
114116
"use client";

v2/thirdpartyemailpassword/nextjs/app-directory/session-helpers.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ export async function withSession(
156156
```
157157

158158
- `getSSRSession` will be used in our frontend routes to get session information when rendering on the server side. This function will:
159-
- `{..., session: Object, hasToken: true}` is a session exists
159+
- `{..., session: Object, hasToken: true}` if a session exists
160160
- `{..., session: undefined, hasToken: false}` if a session does not exist
161-
- `{..., session: undefined, hasToken: true}` if the session is expired
162-
- `{..., session: undefined, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
161+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: false}` if the session is expired
162+
- `{..., session: undefined, hasToken: true, hasInvalidClaims: true}` If the session claims fail their validation. For example if email verification if required but the user's email has not been verified.
163163

164164
- `withSession` will be used as a session guard for each of our API routes. If a session exists it will be passed to the callback, which is where we will write our API logic. If no session exists it will pass `undefined` to the callback. This function will:
165165
- Return status `401` if the session has expired

0 commit comments

Comments
 (0)