> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/react-native/location.md).

# Location

### Detecting location changes

**SDK hook:** `useGeolocation`

`useGeolocation`A hook that returns the device's location information. When the location changes, the value changes too. It detects the current location using GPS information and automatically updates as the user moves. For example, it can be used to display the user's current location in a map-based service or to track real-time routes in a delivery app. You can adjust the accuracy and update frequency of location information, allowing you to maintain the required level of accuracy while minimizing battery consumption.

**Signature**

```typescript
function useGeolocation({ accuracy, distanceInterval, timeInterval }: UseGeolocationOptions): Location | null;
```

**Parameters**

* **options** · Required · `UseGeolocationOptions`

  Configuration object needed for location detection.

  * **options.accuracy** · `Accuracy`

    Sets the location accuracy. `Accuracy.Lowest`: within 3 km margin of error, `Accuracy.Low`: within 1 km margin of error, `Accuracy.Balanced`: within a few hundred meters margin of error, `Accuracy.High`: within 10 m margin of error, `Accuracy.Highest`: highest accuracy, `Accuracy.BestForNavigation`: best accuracy for navigation
  * **options.timeInterval** · `number`

    The minimum interval for updating location information, in milliseconds (ms). This value sets the shortest interval at which location updates occur, but due to system or environmental factors, updates may happen at a longer interval than specified.
  * **options.distanceInterval** · `number`

    Sets the location change distance in meters (m).

**Return value**

* Location | null

  Returns an object containing the device's location information. For details, [Location](/documentation/api-and-sdk-en/common/permission/location.md)please refer to.

**Example**

**Displaying location information on screen**

```tsx
import React, { useState, useCallback } from 'react';
import { View, Text } from 'react-native';
import { useGeolocation, Accuracy } from '@apps-in-toss/framework';

// Detecting location changes
function LocationWatcher() {
  const location = useGeolocation({
    accuracy: Accuracy.Balanced,
    distanceInterval: 10,
    timeInterval: 1000,
  });

  if (location == null) {
    return <Text>Getting location information...</Text>;
  }

  return (
    <View>
      <Text>
        Location information: {location.latitude}, {location.longitude}
      </Text>
    </View>
  );
}
```

**Try the sample app**

[apps-in-toss-examples](https://github.com/toss/apps-in-toss-examples) from the repository [with-location-tracking](https://github.com/toss/apps-in-toss-examples/tree/main/with-location-tracking) Download the code, or scan the QR code below to try it yourself.

QR code link: intoss\://with-location-tracking


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/react-native/location.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
