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: src/content/docs/developer-tools/sdks/backend/nextjs-sdk.mdx
+37-11Lines changed: 37 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1482,29 +1482,55 @@ if (!(await isAuthenticated())) {
1482
1482
1483
1483
Our middleware will automatically refresh the tokens in your session in the background.
1484
1484
1485
-
Sometimes, you may want to refresh these tokens yourself. An example of this is when you update Kinde data via the UI or with the Management API.
1485
+
Sometimes, you may want to refresh these tokens on demand. An example of this is when you update Kinde data via the UI or with the Management API.
1486
1486
1487
-
To have these updates immediately reflected in your app, you will need to get the most up-to-date Kinde data and then refresh the tokens in your session.
1487
+
To immediately get the most up-to-date Kinde data in your session, use the `refreshData` function provided by `useKindeBrowserClient`.
1488
1488
1489
-
To get the most up-to-date Kinde data in your session, use the `refreshTokens` helper function provided by `getKindeServerSession`.
1489
+
<Asidetitle="Warning"type="warning">
1490
+
1491
+
Due to limitations in Next.js, refreshing data on demand can only occur from a client component.
1492
+
1493
+
For more information, see the [Next.js docs](https://nextjs.org/docs/app/api-reference/functions/cookies#understanding-cookie-behavior-in-server-components).
1494
+
1495
+
</Aside>
1490
1496
1491
1497
<Asidetitle="Important">
1492
1498
1493
-
Due to limitations in Next.js, this will only work in a route handler or server action.
1499
+
The `refreshData` function is an asynchronous server action, and it's important to await it
1500
+
so that you receive immediate access to the latest data.
0 commit comments