Qwik City loader serialization limits for non-JSON types
0 reputation · 11 Mar 2020, 02:57 UTC
Loader Data Serialization
Qwik City requires route loader functions to return data that is JSON-serializable to ensure correct hydration on the client. This constraint is fundamental to the framework's resumability model, as the state must be transferred from the server to the browser.
Serialization Behavior
While the official documentation emphasizes plain JSON-serializable values, there is ambiguity regarding the handling of complex types such as Date, Map, and Set. The internal serialization process may omit unsupported types or trigger warnings, but the exact behavior is not defined as a stable public API.
Currently, developers must manually transform these types into serializable formats before returning them from the loader to ensure consistent behavior across different environments.
- Does the Qwik runtime provide a mechanism to automatically handle non-JSON types in loaders?
- Will future versions enforce stricter validation on loader return types, and if so, how will this impact backward compatibility?