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: README.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -600,6 +600,18 @@ This is because the user session is stored in a secure cookie and cannot be acce
600
600
601
601
**This means that you should not rely on the user session during prerendering.**
602
602
603
+
You may also choose to instruct Nuxt AUth Utils to fetch the user session only on the client side, with the `loadStrategy` option in your `nuxt.config.ts`:
604
+
605
+
```ts
606
+
exportdefaultdefineNuxtConfig({
607
+
auth: {
608
+
loadStrategy: 'client-only'
609
+
}
610
+
})
611
+
```
612
+
613
+
When using the `client-only` load strategy, the user session can still be manually fetched on the server side by calling `fetch` from the `useUserSession` composable.
614
+
603
615
### `<AuthState>` component
604
616
605
617
You can use the `<AuthState>` component to safely display auth-related data in your components without worrying about the rendering mode.
@@ -617,7 +629,7 @@ One common use case if the Login button in the header:
617
629
</template>
618
630
```
619
631
620
-
If the page is cached or prerendered, nothing will be rendered until the user session is fetched on the client-side.
632
+
If the page is cached or prerendered or the load strategy set as `client-only`, nothing will be rendered until the user session is fetched on the client-side.
621
633
622
634
You can use the `placeholder` slot to show a placeholder on server-side and while the user session is being fetched on client-side for the prerendered pages:
0 commit comments