0.1.4 ⢠Published 6 months ago
@hammim-in/react-native-places-autocomplete v0.1.4
React Native Places Autocomplete
ā Supports React 19
A lightweight, customizable, and easy-to-use Google Places Autocomplete component for React Native apps.
Built using Google Places API for fast location search with minimal setup.
⨠Features
- š„ Lightweight and fast
- š ļø Fully customizable UI
- š§ Smart debounce (reduces API calls)
- š Supports additional Google Places API query parameters (language, components, sessiontoken, etc.)
- š Works out of the box for iOS and Android
- š Written fully in TypeScript
š¦ Installation
npm install @hammim-in/react-native-places-autocomplete
# or
yarn add @hammim-in/react-native-places-autocompleteUsage
import PlacesAutocomplete from '@hammim-in/react-native-places-autocomplete';
export default function App() {
return (
<PlacesAutocomplete
query={{
language: 'en', // Optional
components: 'country:us', // Optional
}}
placeholder="Search places..."
onPress={(data) => {
console.log('Selected Place:', data);
}}
apiKey='YOUR_GOOGLE_API_KEY' // Required
/>
);
}š ļø Props
| Prop Name | Type | Required | Description |
|---|---|---|---|
apiKey | string | ā Yes | Google Places API query configuration. Must include at least the API key. |
query | Query | ā No | Optional to filter search ressult. |
placeholder | string | ā No | Placeholder text for the search input. Defaults to "Search for places". |
onPress | (data: GooglePlaceData) => void | ā No | Callback function triggered when a place is selected. |
š Query Object
The query prop expects an object with the following structure:
| Key | Type | Required | Description |
|---|---|---|---|
language | string | ā No | Preferred language for results. Example: 'en', 'fr'. |
components | string | ā No | Restrict results to a specific country. Example: 'country:us'. |
sessiontoken | string | ā No | (Optional) Session token for billing optimization. |
| ...and others (offset, location, radius, strictbounds, rankby) |
š Note: key is mandatory; others are optional based on your use-case.
šØ Customization
You can easily customize:
- Input field styles
- Loading indicator
- Result item styles
- Clear button (āļø)
- Debounce timing (default 500ms in code, editable)
- Placeholder text color and input text color
š Advanced Usage
You can extend and modify the component for:
- Handling session tokens to optimize Google billing.
- Limiting to specific place types (e.g., addresses only).
- Adding your own custom render item for search results.
- Adding location bias with latitude/longitude.
š§© Types
GooglePlaceData
interface GooglePlaceData {
description: string;
id: string;
place_id: string;
reference: string;
}
interface Query {
sessiontoken?: string;
offset?: number;
location?: string;
radius?: number;
components?: string;
rankby?: string;
language?: string;
strictbounds?: boolean;
}Example for Screenshots section:
## šø Screenshots
| Search Input | Search Results |
|:-------------|:---------------|
|  |  |š License
MIT License Ā© 2025 Ham Mim
š Support
If you find any issues or have a feature request, feel free to open an issue.
Or contact: support@hammim.in
š§ Future Improvements (Coming Soon)
- Customizable debounce delay
- Add current location ("Use my location") button
- Styling props for better theming
- Support reverse geocoding
- Localization for different languages