react-native-nitro-geolocation 1.1.3 β†’ 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +250 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # react-native-nitro-geolocation
2
+
3
+ [![NPM](https://img.shields.io/npm/v/react-native-nitro-geolocation)](https://www.npmjs.com/package/react-native-nitro-geolocation)
4
+
5
+ **Simple and Modern Geolocation for React Native** β€” Powered by Nitro Modules with JSI
6
+
7
+ A complete reimplementation of [`@react-native-community/geolocation`](https://github.com/michalchudziak/react-native-geolocation) for the React Native New Architecture, featuring:
8
+
9
+ - 🎯 **Simple functional API** β€” Direct function calls, no complex abstractions
10
+ - ⚑ **JSI-powered performance** β€” Direct native calls without the Bridge
11
+ - πŸ” **100% API compatibility** via `/compat` for easy migration
12
+ - 🧹 **Automatic cleanup** β€” No manual subscription management
13
+ - πŸ“± **Consistent behavior** across iOS and Android
14
+ - πŸ› οΈ **DevTools Plugin** β€” Mock locations with interactive map (Rozenite)
15
+
16
+ ![react-native-nitro-geolocation](https://raw.githubusercontent.com/jingjing2222/react-native-nitro-geolocation/main/demo.gif)
17
+
18
+ ---
19
+
20
+ ## πŸ“˜ Documentation
21
+
22
+ Full documentation available at:
23
+ πŸ‘‰ [https://react-native-nitro-geolocation.pages.dev](https://react-native-nitro-geolocation.pages.dev)
24
+
25
+ ---
26
+
27
+ ## 🧭 Introduction
28
+
29
+ React Native Nitro Geolocation provides **two APIs** to fit your needs:
30
+
31
+ ### 1. Modern API (Recommended)
32
+
33
+ **Simple functional API** with direct calls and a single hook for tracking:
34
+
35
+ ```tsx
36
+ import {
37
+ setConfiguration,
38
+ requestPermission,
39
+ getCurrentPosition,
40
+ useWatchPosition,
41
+ } from "react-native-nitro-geolocation";
42
+
43
+ // Configure once at app startup
44
+ setConfiguration({
45
+ authorizationLevel: "whenInUse",
46
+ locationProvider: "auto",
47
+ });
48
+
49
+ // Request permission
50
+ const status = await requestPermission();
51
+
52
+ // Get current location
53
+ const position = await getCurrentPosition({
54
+ enableHighAccuracy: true,
55
+ });
56
+
57
+ // Continuous tracking with hook
58
+ function LocationTracker() {
59
+ const { position, error, isWatching } = useWatchPosition({
60
+ enabled: true,
61
+ enableHighAccuracy: true,
62
+ distanceFilter: 10,
63
+ });
64
+
65
+ if (error) return <Text>Error: {error.message}</Text>;
66
+ if (!position) return <Text>Waiting...</Text>;
67
+
68
+ return (
69
+ <Text>
70
+ {position.coords.latitude}, {position.coords.longitude}
71
+ </Text>
72
+ );
73
+ }
74
+ ```
75
+
76
+ **Benefits**:
77
+
78
+ ### 2. Legacy API (Compatibility)
79
+
80
+ **Drop-in replacement** for `@react-native-community/geolocation`:
81
+
82
+ ```tsx
83
+ import Geolocation from "react-native-nitro-geolocation/compat";
84
+
85
+ Geolocation.getCurrentPosition(
86
+ (position) => console.log(position),
87
+ (error) => console.error(error),
88
+ { enableHighAccuracy: true }
89
+ );
90
+
91
+ const watchId = Geolocation.watchPosition((position) => console.log(position));
92
+ Geolocation.clearWatch(watchId);
93
+ ```
94
+
95
+ ---
96
+
97
+ ## ⚑ Quick Start
98
+
99
+ ### 1. Installation
100
+
101
+ ```bash
102
+ # Install Nitro core and Geolocation module
103
+ yarn add react-native-nitro-modules react-native-nitro-geolocation
104
+
105
+ # or using npm
106
+ npm install react-native-nitro-modules react-native-nitro-geolocation
107
+ ```
108
+
109
+ Rebuild your native app:
110
+
111
+ ```bash
112
+ cd ios && pod install
113
+ ```
114
+
115
+ ---
116
+
117
+ ### 2. iOS Setup
118
+
119
+ Add permissions to your **Info.plist**:
120
+
121
+ ```xml
122
+ <key>NSLocationWhenInUseUsageDescription</key>
123
+ <string>This app requires access to your location while it's in use.</string>
124
+ <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
125
+ <string>This app requires access to your location at all times.</string>
126
+ ```
127
+
128
+ ---
129
+
130
+ ### 3. Android Setup
131
+
132
+ Add permissions to **AndroidManifest.xml**:
133
+
134
+ ```xml
135
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
136
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
137
+ ```
138
+
139
+ Optional (for background):
140
+
141
+ ```xml
142
+ <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
143
+ ```
144
+
145
+ ---
146
+
147
+ ### 4. Development Tools (Optional)
148
+
149
+ #### DevTools Plugin (Rozenite)
150
+
151
+ > **Prerequisites**: Requires [Rozenite DevTools](https://github.com/rozenite/rozenite) to be installed.
152
+ >
153
+ > **API Compatibility**: Only works with the Modern API. Does not support the Legacy API (`/compat`).
154
+
155
+ Mock geolocation data during development with an interactive map interface:
156
+
157
+ ![DevTools Plugin](https://raw.githubusercontent.com/jingjing2222/react-native-nitro-geolocation/main/devtools.gif)
158
+
159
+ ```bash
160
+ npm install @react-native-nitro-geolocation/rozenite-plugin
161
+ # or
162
+ yarn add @react-native-nitro-geolocation/rozenite-plugin
163
+ ```
164
+
165
+ **Setup**:
166
+
167
+ ```tsx
168
+ import {
169
+ useGeolocationDevTools,
170
+ createPosition,
171
+ } from "@react-native-nitro-geolocation/rozenite-plugin";
172
+
173
+ function App() {
174
+ // Enable location mocking in development
175
+ useGeolocationDevTools({
176
+ initialPosition: createPosition("Seoul, South Korea"),
177
+ });
178
+
179
+ return <YourApp />;
180
+ }
181
+ ```
182
+
183
+ **Features**:
184
+
185
+ - πŸ—ΊοΈ Interactive Leaflet map interface
186
+ - πŸ“ Click to set location instantly
187
+ - ⌨️ Arrow key navigation for precise control
188
+ - πŸ™οΈ 20 pre-configured city presets
189
+ - ✏️ Manual latitude/longitude input
190
+ - πŸ“Š Real-time heading, speed, and accuracy calculation
191
+ - πŸŒ“ Dark mode support
192
+
193
+ [See full DevTools guide β†’](https://react-native-nitro-geolocation.pages.dev/guide/devtools)
194
+
195
+ ---
196
+
197
+ ### 5. Usage
198
+
199
+ #### Modern API (Recommended)
200
+
201
+ ```tsx
202
+ // Get current location
203
+ const position = await getCurrentPosition({ enableHighAccuracy: true });
204
+
205
+ // Real-time tracking with hook
206
+ const { position, error } = useWatchPosition({
207
+ enabled: true,
208
+ distanceFilter: 10
209
+ });
210
+ ```
211
+
212
+ #### Legacy API (Compatibility)
213
+
214
+ ```tsx
215
+ import Geolocation from "react-native-nitro-geolocation/compat";
216
+
217
+ Geolocation.getCurrentPosition((pos) => console.log(pos));
218
+ const watchId = Geolocation.watchPosition((pos) => console.log(pos));
219
+ Geolocation.clearWatch(watchId);
220
+ ```
221
+
222
+ ---
223
+
224
+ ---
225
+
226
+ ## πŸ”„ Migration from `@react-native-community/geolocation`
227
+
228
+ Change the import to use `/compat` β€” 100% API compatible:
229
+ ```diff
230
+ - import Geolocation from '@react-native-community/geolocation';
231
+ + import Geolocation from 'react-native-nitro-geolocation/compat';
232
+ ```
233
+
234
+ ---
235
+
236
+ ## πŸ“– Learn More
237
+
238
+ - [Introduction](https://react-native-nitro-geolocation.pages.dev/guide/)
239
+ - [Quick Start Guide](https://react-native-nitro-geolocation.pages.dev/guide/quick-start)
240
+ - [Modern API Reference](https://react-native-nitro-geolocation.pages.dev/guide/modern-api)
241
+ - [Legacy API Reference](https://react-native-nitro-geolocation.pages.dev/guide/legacy-api)
242
+ - [DevTools Plugin Guide](https://react-native-nitro-geolocation.pages.dev/guide/devtools)
243
+ - [Why Nitro Module?](https://react-native-nitro-geolocation.pages.dev/guide/why-nitro-module)
244
+ - [Benchmark Results](https://react-native-nitro-geolocation.pages.dev/guide/benchmark)
245
+
246
+ ---
247
+
248
+ ## License
249
+
250
+ MIT License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-geolocation",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "βš‘πŸš€Blazing-fast geolocation for React Native powered by Nitro Modules",
5
5
  "main": "src/index",
6
6
  "source": "src/index",