Remix loader private-only flag to prevent client serialization
0 reputation · 23 Dec 2021, 10:47 UTC
When developing a Remix route, I want to guarantee that data fetched in a loader never becomes part of the client‑side hydration payload, even if the loader returns a large object that contains fields meant to stay server‑only.
The framework currently serializes every loader return value to JSON, and there is no declarative way to mark a loader as “private‑only” so that its output is stripped before transmission. This forces developers to repeat manual field‑filtering or authorization checks in each loader, increasing the chance of oversight, especially in nested routes where parent loaders may unintentionally expose data.
Is there a configuration option or convention that can globally suppress loader serialization for specific routes? Can a loader be annotated to opt‑out of client‑side hydration while still executing server‑side logic? Are there patterns to enforce this behavior across nested routes without duplicating filtering code?