# Browser

Compass supports [HTML5 Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API) with the `compass-geolocation-browser` artifact. The artifact supports JS and WASM targets.

Geolocation in the browser requires the user to provide permission. This is handled automatically when you start tracking or attempt to get the current location.

{% hint style="info" %}
If your project supports both Browser and other targets, you need to configure your setup to provide a `Geolocator` for each platform. Check out [Mixed platforms](/setup/mixed-platforms.md)for more information.
{% endhint %}

## Usage

Follow these steps to create a `Geolocator`

### Create Locator

Geolocator is powered by the `Locator` object:

```kotlin
val locator: Locator = createBrowserLocator()
val locator: Locator = Locator.browser()
```

### Create Geolocator

Then you can use that to create the `Geolocator` object:

```kotlin
val geolocator: Geolocator = Geolocator(locator)
```

Or you can use an extension function to skip the `Locator` step:

```kotlin
val geolocator: Geolocator = Geolocator()
val geolocator: Geolocator = BrowserGeolocator()
val geolocator: Geolocator = Geolocator.browser()
```

## Permissions

Nothing extra is required to setup permissions for the browser.

When you attempt to get the location, the browser will show a prompt to the user. They can allow, deny, or do one of those permanently.

## Get location

Now you can follow the steps in [Geolocator](/geolocation/geolocator.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://compass.jordond.dev/geolocation/browser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
