Docyrus

PlaceAutocomplete

A location search input with autocomplete suggestions powered by the Photon geocoding API, with location bias, bounding boxes and web-parity address formatting.

iOSAndroid
Preview PlaceAutocomplete on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-place-autocomplete

Usage

import { PlaceAutocomplete, type PlaceFeature } from '@/components/docyrus-native/place-autocomplete';

const [address, setAddress] = useState('');

<PlaceAutocomplete
  value={address}
  onChange={setAddress}
  onPlaceSelect={(feature: PlaceFeature) => {
    const [lon, lat] = feature.geometry.coordinates;
    saveLocation({ lat, lon });
  }}
/>

Uncontrolled

<PlaceAutocomplete defaultValue="Berlin" onPlaceSelect={handleSelect} />

Location bias & bounding box

<PlaceAutocomplete
  lang="tr"
  lat={41.0082}
  lon={28.9784}
  zoom={12}
  locationBiasScale={0.5}
  bbox={[28.5, 40.8, 29.5, 41.3]}
  onResultsChange={(results) => setCount(results.length)}
/>

Variants & sizes

<PlaceAutocomplete variant="outline" size="sm" />
<PlaceAutocomplete variant="ghost" size="lg" />

Behaviour

  • Typing sets the search query; the Photon request fires after debounceMs and is aborted when the query changes. Results are de-duplicated by osm_id.
  • Selecting a result writes formatAddress(properties) into the input (via onChange), clears the result list and calls onPlaceSelect(feature).
  • The result panel shows an error row, a "No places found for …" row, or the results (name / street + formatted address). It closes after a selection or a clear.
  • Address formatting (web parity): name, housenumber street (or street), city (falls back to locality), state (skipped when equal to city), country — duplicates removed.
  • An inline bbox={[…]} array is compared by value, so it never refires the search on re-render.

Translations

KeyEnglish fallback
ui.placeAutocomplete.searchPlacesSearch places... (placeholder when placeholder is not set)
ui.placeAutocomplete.clearSearchClear search (clear button accessibility label)
ui.placeAutocomplete.errorError:
ui.placeAutocomplete.noPlacesFoundNo places found for
ui.placeAutocomplete.unknownUnknown (result without a name or street)

API Reference

PlaceAutocompleteProps

PropTypeDefaultDescription
valuestring—Current input value (controlled).
defaultValuestring''Initial input value (uncontrolled).
onChange(value: string) => void—Called when the input value changes — typing, selecting a place, clearing.
onValueChange(value: string) => void—Deprecated alias of onChange (called alongside it).
onPlaceSelect(feature: PlaceFeature) => void—Called when a place is selected from the results.
onResultsChange(results: PlaceFeature[]) => void—Called whenever the result list changes.
debounceMsnumber300Debounce delay in milliseconds before searching.
langstring—Preferred result language ("en", "de", "fr"…). Omitted → Photon default (local names).
limitnumber5Maximum number of results.
bbox[number, number, number, number]—Restricts results to [minLon, minLat, maxLon, maxLat].
latnumber—Latitude to bias results toward (requires lon).
lonnumber—Longitude to bias results toward (requires lat).
zoomnumber—Zoom level for location biasing (higher = more local).
locationBiasScalenumber—Strength of the location bias.
variant'default' | 'outline' | 'ghost''default'Visual style of the input.
size'sm' | 'default' | 'md' | 'lg''default'Input size. 'md' is an alias of 'default'.
placeholderstring'Search places...'Placeholder text.
disabledbooleanfalseDisables the input.
refRef<TextInput>—Ref to the underlying TextInput.
classNamestring—Additional classes for the container.
inputClassNamestring—Additional classes for the TextInput.
styleStyleProp<ViewStyle>—Container style.
...TextInputPropsTextInputProps—Other TextInput props (onFocus, onBlur, returnKeyType, testID, …) are forwarded. onFocus / onBlur are chained.

PlaceSearchOptions

FieldTypeDescription
querystringSearch text (address, place name or POI).
langstringPreferred language for results.
limitnumberMaximum number of results.
bbox[number, number, number, number]Bounding box [minLon, minLat, maxLon, maxLat].
latnumberLatitude for location bias.
lonnumberLongitude for location bias.
zoomnumberZoom level for location bias.
locationBiasScalenumberStrength of the location bias.

PlaceFeature

FieldTypeDescription
type'Feature'GeoJSON feature type
geometry{ type: 'Point'; coordinates: [number, number] }GeoJSON point geometry with [longitude, latitude]
propertiesPlaceFeaturePropertiesAddress and metadata properties

PlaceFeatureProperties

FieldTypeDescription
osm_idnumberOpenStreetMap ID
osm_type'N' | 'W' | 'R'OSM element type (Node, Way, Relation)
osm_keystringOSM key (e.g. place, amenity)
osm_valuestringOSM value (e.g. city, cafe)
typestringPhoton result type (house, street, city, …)
namestring?Place name
housenumberstring?House number
streetstring?Street name
localitystring?Locality (used when city is missing)
districtstring?District
postcodestring?Postal code
citystring?City name
countystring?County
statestring?State or province
countrystring?Country name
countrycodestring?ISO country code
extent[number, number, number, number]?Bounding extent of the feature

Type Exports

TypeDescription
PlaceAutocompletePropsProps for the PlaceAutocomplete component
PlaceAutocompleteVariant'default' | 'outline' | 'ghost'
PlaceAutocompleteSize'sm' | 'default' | 'md' | 'lg'
PlaceSearchOptionsPhoton search options
PlaceFeatureGeoJSON feature returned by the geocoding API
PlaceFeaturePropertiesAddress properties of a place feature

On this page