Subscribe on changes!

getSSRProps has no access to vnode

avatar
Jan 6th 2024

Vue version

3.4.5

Link to minimal reproduction

https://stackblitz.com/edit/vue-issues-10026

Steps to reproduce

  1. Use getSSRProps
  2. Check the 2nd argument (vNode)
  3. See it always it empty

What is expected?

vNode should be available so you can update or change class values via SSR directives. Right now, you can provide a "default value" when rendering on the server but have no information which values the vnode would have, only the binding which might not be enough.

One use case would be altering classes based on dedupe-logic (e.g. merging tailwind classes).

What is actually happening?

vNode is always null

System Info

No response

Any additional comments?

A workaround would be using component + slots, but that seems tedious if used for a huge amount of elements.

avatar
Jan 6th 2024

Hey Alex, I think you inserted the wrong link for the repro.

avatar
Jan 7th 2024

Hey Thorsten! Whoops, you are right, my bad. Updated the link 🙏

avatar
Jan 7th 2024

@edison1105 Yes I noticed that too. Is there any way to opt out of the optimization and receive the actual vnode?

avatar
Jan 8th 2024

@edison1105 Yes I noticed that too. Is there any way to opt out of the optimization and receive the actual vnode?

there seems no other way except for what you mentioned above.

avatar
Jan 8th 2024

The purpose of getSSRProps isn't for you to alter the vnode - you are not supposed to mutate anything, only returning additional props to be added. It also needs to work for both optimized and vdom based SSR, so there is no way to provide the vnode when there is no vdom being created.