Skip to content
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

State marked with skipHydrate should not be included in the Nuxt payload #2773

Open
kabalage opened this issue Sep 16, 2024 · 3 comments
Open

Comments

@kabalage
Copy link

What problem is this solving

I expected that skipHydrate would also leave the ref out of the Nuxt payload. Nuxt throws errors when it cannot serialize certain objects. I could keep unserializable stuff out of the pinia stores, but I don't like the idea of introducing multiple solutions for shared state. I would much prefer to use Pinia for all shared state.

Example CodeSandbox

Proposed solution

Make skipHydrate also skip transferring of values to the nuxt payload.

Describe alternatives you've considered

No response

Copy link
Member

posva commented Sep 16, 2024

This should be doable with a payload plugin that turns marked properties into into undefined or any other value

@posva posva added contribution welcome ⛰ pkg:nuxt Related to @pinia/nuxt labels Sep 16, 2024 — with Volta.net
Copy link
Member

posva commented Sep 16, 2024

BTW, you can (and should)use that for complex state. I go into all the details in my mastering pinia course

@kabalage
Copy link
Author

kabalage commented Sep 16, 2024

I think I just did that. I created a wrapper called skipSerialize(), in which I used a Symbol to mark the object similarly to how skipHydrate does it, and then I used definePayloadPlugin() to take control of its serialization.

Would it be beneficial to include this (or something similar) in the core library, or would you prefer to keep it separate? I could set up a PR if you're interested.

Edit: Yeah I agree that this is not something you want to do often, but we need it in a particularly complex part of our app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants