User Location Action
A reference page in my new Starlight docs site.
The useCurrentLocation
action allows you to retrieve the user’s current location (such as their geographical coordinates) within your theme.
You can use this information to customize content based on the user’s location (e.g., showing relevant products or adjusting shipping options).
Basic Usage
-
To trigger the
useCurrentLocation
action, include it in your component configuration. For example:{ "type": "image-button", "url": "{{themeUrl}}/img/common/locationPinGray.svg", "action": "useCurrentLocation" }
-
In this example, when the user interacts with the image button (displaying a gray location pin), your theme will request their current location.
-
Use Cases:
- Display nearby stores based on the user’s location.
- Offer personalized promotions or discounts based on their geographical area.
On This Page