Files
fuel-price/.agents/skills/vueuse-functions/references/useGeolocation.md
Ovidiu U 4a3ce4cc1d
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
docs: add advanced skills for Vitest, Pinia, and Vue built-ins
Add comprehensive reference documentation for:
- Vitest: environments, projects/workspaces, type testing, vi utilities
- Pinia: HMR, Nuxt integration, SSR setup
- Vue: built-in components (Transition, Teleport, Suspense, KeepAlive) and advanced directives
2026-04-11 16:28:36 +01:00

64 lines
2.5 KiB
Markdown

---
category: Sensors
---
# useGeolocation
Reactive [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API). It allows the user to provide their location to web applications if they so desire. For privacy reasons, the user is asked for permission to report location information.
## Usage
```ts
import { useGeolocation } from '@vueuse/core'
const { coords, locatedAt, error, resume, pause } = useGeolocation()
```
| State | Type | Description |
| --------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| coords | [`Coordinates`](https://developer.mozilla.org/en-US/docs/Web/API/Coordinates) | information about the position retrieved like the latitude and longitude |
| locatedAt | `Date` | The time of the last geolocation call |
| error | `string` | An error message in case geolocation API fails. |
| resume | `function` | Control function to resume updating geolocation |
| pause | `function` | Control function to pause updating geolocation |
## Config
`useGeolocation` function takes [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) object as an optional parameter.
## Component Usage
```vue
<template>
<UseGeolocation v-slot="{ coords: { latitude, longitude } }">
Latitude: {{ latitude }}
Longitude: {{ longitude }}
</UseGeolocation>
</template>
```
## Type Declarations
```ts
export interface UseGeolocationOptions
extends Partial<PositionOptions>, ConfigurableNavigator {
immediate?: boolean
}
export interface UseGeolocationReturn extends Supportable {
coords: Ref<Omit<GeolocationPosition["coords"], "toJSON">>
locatedAt: ShallowRef<number | null>
error: ShallowRef<GeolocationPositionError | null>
resume: () => void
pause: () => void
}
/**
* Reactive Geolocation API.
*
* @see https://vueuse.org/useGeolocation
* @param options
*/
export declare function useGeolocation(
options?: UseGeolocationOptions,
): UseGeolocationReturn
```