New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stablise id
s for SSR
#331
Comments
The I think there's mainly two ways to solve:
These can be combined, so you fallback to client only id if the contextprovider isn't provided. Reach UI has given it a lot of thought: I've also made my own attempt at it, with support for an optional ContextProvider: |
I think the simplest solution for our case is probably to skip the ID altogether on the server. For the vast majority of our needs, the ID is needed for proper labeling for AT which isn't really useful on the server anyway (and AT users won't benefit from our components without client-side JS anyway). In the strange event that someone needs a stable ID on the server, they can always pass their own IDs which should overwrite anything we do with |
I feel like the web is going to become more and more interested in SSR and progressive enhancement again (especially with Remix v1 approaching) and would love for our components to support that movement. What if a screen reader user has JS disabled in this case? Or doesn't manage to download the JS bundle in time before a connection outage? Or even just has a slow connection? Our accessibility would be broken until client bundle finished downloading (Time To Interactive for SR users). There has been an experimental React release with a I am on board with doing the client only thing as a stopgap to prevent errors for folk while we look into all this though. |
I don't think it really matters all that much whether or not an ID renders on the server in most cases so long as we don't create a mismatch during hydration. That's kind of where we landed in Reach UI. If a user disables JS, none of our accessibility features will work anyway so the IDs existing or not won't really improve the experience that much without some progressive enhancement work by consumers. I looked at
Yes! I really hope when this is stable we can just use it internally and keep our API for |
I'm down with the idea of having no ids on the server and just waiting for hydration. Implementation should be pretty simple too? |
useId
hook gives differentid
between server and clientThe text was updated successfully, but these errors were encountered: