1.2.0: Hydration support added (with only 12 more bytes) #114
Replies: 6 comments
-
Great job!✌️ |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
There is no change in the implementation of |
Beta Was this translation helpful? Give feedback.
-
There is no change in the implementation of |
Beta Was this translation helpful? Give feedback.
-
There is no change in the implementation of |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hi fellow VanJSers,
I'm happy to announce the release of VanJS
1.2.0
. 🎉🎉🎉The most notable feature in
1.2.0
is the official hydration support with the introduction of new APIvan.hydrate
. With the1.2.0
release, we can finally have the officially-supported solution for fullstack rendering in VanJS.The major steps of building a fullstack web app with SSR, CSR and hydration will be like below:
van.hydrate
API to add interactivity for all existing SSR components.You can refer to https://vanjs.org/ssr for a detailed walkthrough on building a sample fullstack app.
These are the major things we have done to enable the fullstack rendering and hydration:
0.4.0
release, we make Mini-Van compatible to all the states and state binding related API in VanJS (though with the absence of reactivity). This is crucial for cross-platform UI components to work on both VanJS (client-side) and Mini-Van (server-side).1.2.0
, we implement the new APIvan.hydrate
to support hydration. Essentially,van.hydrate
allows us to specify a hydration function to describe how an SSR component can be converted into a CSR component with added reactivity, while preserving all the server-side states. Here is an example of howvan.hydrate
can be used:Other changes in
1.2.0
release:van-{VERSION}.debug.js
to allow string values inon...
properties of tag functions, if the properties are used to set HTML attributes (viasetAttribute
) of the DOM element. This is crucial for cross-platform UI components to specify event handlers, as for SSR, only string-valuedon...
event handlers can be visible in the rendered HTML strings. You can refer to https://vanjs.org/ssr#on-properties for a detailed explanation.van.d.ts
:val
property toPrimitive | null | undefined
(DOM-node-valued states are not allowed anymore). This is because DOM-node-valued states have problematic behavior and should be generally avoided, see https://vanjs.org/advanced#why-not-dom-valued-states for more information.(dom: Node | undefined) => ValidChildDomValue
(changed from(dom: Node) => ValidChildDomValue
), as it needs to handle to case where thedom
parameter isundefined
(when the binding function is invoked for the first time).Props
with built-in typeRecord
.With the newly added hydration support, the bundle size increases slightly. Gzipped bundle increases to
970 bytes
from958 bytes
(12 more bytes), which remains at0.9kB
. Minified bundle increases to1729 bytes
from1702 bytes
, which remains at1.7kB
. Thus, it's fair to say that in1.2.0
release, we achieved hydration support with only 12 more bytes, still being the smallest reactive UI framework in the world.❤️ Hope you can enjoy!
Beta Was this translation helpful? Give feedback.
All reactions