SolidJSS
SolidJSโ€ข3y agoโ€ข
9 replies
James

Get SSR attribute value when hydrating

Hi guys! The server generates an attribute value for an element and I don't want to re-generate that attribute value on the browser side because it's unnecessary load on the user device. Is it possible to access the to-be-updated element from within the client side component function code?

e.g.
const myAttr = createSignal(isServer ? doHeavyCalculationThing() : hydrationEl.dataset.myAttr);

// return JSX using myAttr


I do still need the doHeavyCalculationThing's code to be given to the client as it will need to re-calculate after an interaction.

cheers!
Was this page helpful?