Fix SSR hydration mismatches caused by createId function #1521
Labels
bug
Something isn't working or not shown correctly
dependencies
Pull requests that update a dependency file
dev
Requires technical expertise
Milestone
This bug is intended to work as a "TODO" to fix this issue once vue 3.5 is out.
Version
1.0.0-beta.0
Description
Some of the onyx components cause hydration mismatches when using server side rendering.
This is caused by the ids generated to e.g. link labels or other aria attributes. At the moment the ids for that are generated using a global counter variable stored inside a IIFE (see packages/headless/src/utils/id.ts). Using a global counter causes issues during SSR as the state of the counter will be preserved on the server across requests while being reset on the client:
The easiest solution to the problem would probably be to wait vor vue 3.5 which should include a new composable called
useId()
. This composable creates SSR safe unique ids for such usecases. (There is a discussion in progress regarding this issue: vuejs/rfcs#557)Reproduction steps
Use a SSR framework like e.g. Nuxt Js to render Onyx components on the server and hydrate them on the client.
Confirmations
The text was updated successfully, but these errors were encountered: