Skip to content

docs: add tip when mixing universal and server load #11822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions documentation/docs/20-core-concepts/20-load.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export async function load({ data }) {
}
```

> It's important to not modify `data` to include any non-serializable objects since it will be processed by the **server** `load` after the **universal** `load` returns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"[...] processed by the server load [...]"

Is not quite right. It is just that the result of the server load gets serialized for hydration, and you can modify this result (the data prop) in the universal load function (which runs right after the server load function and before the serialization of the server load function's result).

Maybe this bug could also be fixed if we serialize the server load function's result before running the universal load function.


## Using URL data

Often the `load` function depends on the URL in one way or another. For this, the `load` function provides you with `url`, `route` and `params`.
Expand Down
Loading