A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Geolocation Client Hint



I would like to discuss with this group a proposal to solve the following use case:

Currently, the only mechanism to share your geolocation with a website is through the JS Geolocation API. This means that in order to have the server know the client’s location there are two full roundtrips required (one roundtrip to load the page with Javascript code, and a second roundtrip to actually send the location to the server and get back a location-aware response).

For example, for services like Search, it means that the very first response from a server will contain non-localized results, and a second roundtrip would be required to refresh those results (assuming Geolocation permission is already granted for the origin).

It looks like Client Hints (CH) would be a great mechanism to solve this use case, so I started a draft trying to explain how a CH-extension could look like. You can find it here: https://github.com/luisbargu/geolocation-client-hint

It would be great to get your opinion on this, and whether this is something that might be interesting for people in this group.

Thanks! Luis


I like this idea. Just want to reiterate what is said in the spec, that permission should be first granted through the JS Geolocation API; meaning that the browser shouldn’t prompt the user on its own.


I have been working on a more detailed spec for a Geolocation Client Hint. Preview here.

In the introduction, I added some client/server flows which hopefully make clear that the permission should be first granted through the JS Geolocation API (as @matthewp mentioned). It also highlights what the current problem is, and how/why this proposal would improve the situation.

If anyone else is interested in this idea, please let me know.