getSSRProps has no access to vnode
Vue version
3.4.5
Link to minimal reproduction
https://stackblitz.com/edit/vue-issues-10026
Steps to reproduce
- Use
getSSRProps
- Check the 2nd argument (
vNode
) - 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.
It is always null in SSR optimization mode. That may be a limitation. https://github.com/vuejs/core/blob/bfe6b459d3a0ce6168611ee1ac7e6e789709df9d/packages/server-renderer/src/helpers/ssrGetDirectiveProps.ts#L12-L22
@edison1105 Yes I noticed that too. Is there any way to opt out of the optimization and receive the actual vnode?
@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.