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
The above example shows two `routeLoader$`s being used in the same file. A generic `useLoginStatus` loader is used to check if the user is logged in, and a more specific `useCurrentUser` loader is used to retrieve the user data.
126
127
128
+
## Loaders data serialization
129
+
130
+
By default, route loader data is not serialized and sent to the client. Instead, it is discarded after server-side rendering (SSR). If a component on the client requires the data, it will be refetched (lazy-loaded).
131
+
132
+
You can customize this behavior using the `serializationStrategy` option in the `routeLoader$()`. This option accepts one of three values:
133
+
-`never` (Default): The data is never serialized. It is discarded after SSR and refetched on the client when needed.
134
+
-`always`: The data is always serialized and included in the initial HTML response. It is immediately available on the client without needing to be refetched.
135
+
-`auto`: Qwik automatically decides whether to serialize the data based on its size. If the data is small, it will be serialized. If it exceeds a certain threshold, it will be discarded and lazy-loaded on the client as needed.
### Handling loading state for lazy loaded route loader data
152
+
153
+
When using lazy-loaded data, you can handle the loading state in your Qwik Components by checking if the data is available. If not, you can render a loading indicator or placeholder content.
Just like [middleware](/docs/middleware/) or [endpoint](/docs/endpoints/)`onRequest` and `onGet`, `routeLoader$`s have access to the [`RequestEvent`](/docs/middleware#requestevent) API which includes information about the current HTTP request.
0 commit comments