leptos-use icon indicating copy to clipboard operation
leptos-use copied to clipboard

Add support for client hints

Open dvtkrlbs opened this issue 1 year ago • 8 comments

Client hints currently experimental. Maybe we can implement some features of it using a feature flag. Especially the Sec-CH-Prefers-Color-Scheme header could be useful to setup dark mode on the server to prevent flash on non dark mode content.

dvtkrlbs avatar Jun 15 '24 22:06 dvtkrlbs

Sounds like a good idea. First we have to add a PR to web_sys to support the API.

maccesch avatar Jun 16 '24 12:06 maccesch

@maccesch from what I read it doesn't need any kind of client side feaute. Since everything only via headers. We just need the integration via axum since at first response server responds with critical hints and client retries the request.

dvtkrlbs avatar Jun 16 '24 15:06 dvtkrlbs

For #101 we only need the server side part indeed because the client side is already handled. But even in that case we're probably interested in being able to read it on the client as well.

For a general purpose client hints function we definitely need client side. Pages should work the same as much as possible between being rendered on the server or on the client.

This is the client API: https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API

maccesch avatar Jun 17 '24 13:06 maccesch

I made a PR for web_sys: https://github.com/rustwasm/wasm-bindgen/pull/3989

maccesch avatar Jun 17 '24 13:06 maccesch

@maccesch these are the user agent client hints api and I was mostly considerign User preference media features client hints css features where you can get for example Sec-CH-Prefers-Reduced-Motion, Sec-CH-Prefers-Color-Scheme. These already have client side apis. But yeah for the user agent ones that makes sense.

dvtkrlbs avatar Jun 17 '24 21:06 dvtkrlbs

Yes, but while we're at it we might as well do it right, don't you agree?

As far as I read it you're talking about a subset but when we implement this API I'd rather do it all at once.

maccesch avatar Jun 17 '24 21:06 maccesch

@dvtkrlbs I finally fully understood what you meant with existing client APIs. The Sec-CH-Prefers-Color-Scheme is now implemented.

maccesch avatar Aug 13 '24 15:08 maccesch

@dvtkrlbs I finally fully understood what you meant with existing client APIs. The Sec-CH-Prefers-Color-Scheme is now implemented.

Thank you very much

dvtkrlbs avatar Aug 15 '24 14:08 dvtkrlbs