0.1.4 • Published 6 months ago

@hammim-in/react-native-places-autocomplete v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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-autocomplete

Usage

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 NameTypeRequiredDescription
apiKeystringāœ… YesGoogle Places API query configuration. Must include at least the API key.
queryQueryāŒ NoOptional to filter search ressult.
placeholderstringāŒ NoPlaceholder text for the search input. Defaults to "Search for places".
onPress(data: GooglePlaceData) => voidāŒ NoCallback function triggered when a place is selected.

šŸ“‹ Query Object

The query prop expects an object with the following structure:

KeyTypeRequiredDescription
languagestringāŒ NoPreferred language for results. Example: 'en', 'fr'.
componentsstringāŒ NoRestrict results to a specific country. Example: 'country:us'.
sessiontokenstringāŒ 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 |
|:-------------|:---------------|
| ![Input Example](link-to-image-1) | ![Result Example](link-to-image-2) |

šŸ“„ 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
0.1.4

6 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago