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
+39-12Lines changed: 39 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -331,7 +331,6 @@ You can get an authorized user’s Kinde Auth data from any server component usi
331
331
|[`getBooleanFlag`](#getbooleanflag)| Get a boolean feature flag |
332
332
|[`getIntegerFlag`](#getintegerflag)| Get an integer feature flag |
333
333
|[`getStringFlag`](#getstringflag)| Get a string feature flag |
334
-
|[`refreshTokens`](#refreshtokens)| Refresh tokens to get up-to-date Kinde data |
335
334
|[`getAccessToken`](#getaccesstoken)| Get the decoded access token |
336
335
|[`getAccessTokenRaw`](#getaccesstokenraw)| Get the access token |
337
336
|[`getIdToken`](#getidtoken)| Get the decoded ID token |
@@ -1483,29 +1482,57 @@ if (!(await isAuthenticated())) {
1483
1482
1484
1483
Our middleware will automatically refresh the tokens in your session in the background.
1485
1484
1486
-
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.
1487
1486
1488
-
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`.
1489
1488
1490
-
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
+
This utility only works in Next.js 14 and above. Attempting to use it in an older version will result in a warning.
1492
+
1493
+
Due to limitations in Next.js, refreshing data on demand can only occur from a client component.
1494
+
1495
+
For more information, see the [Next.js docs](https://nextjs.org/docs/app/api-reference/functions/cookies#understanding-cookie-behavior-in-server-components).
1496
+
1497
+
</Aside>
1491
1498
1492
1499
<Asidetitle="Important">
1493
1500
1494
-
Due to limitations in Next.js, this will only work in a route handler or server action.
1501
+
The `refreshData` function is an asynchronous server action, and it's important to await it
1502
+
so that you receive immediate access to the latest data.
0 commit comments