react-places-autocomplete is a React component designed to integrate Google Maps Places Autocomplete functionality into web applications, allowing users to easily select addresses. The current stable version is 7.3.0, released in January 2024. The library offers a highly customizable user interface, utility functions for geocoding addresses, and retrieving latitude and longitude coordinates using the Google Maps Geocoding API. Key differentiators include full control over rendering, mobile-friendly user experience, WAI-ARIA compliance, and support for asynchronous loading of the Google Maps JavaScript API. The project is actively seeking new maintainers, which may impact its long-term development cadence and responsiveness to new features or complex issues. Despite recent minor updates, significant feature development might be slow without additional community contributions.
npm install react-places-autocompleteVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic React class component that integrates `react-places-autocomplete`. It shows how to initialize the component, handle input changes, and process selected addresses to retrieve their latitude and longitude using the provided utility functions. It assumes the Google Maps JavaScript API is loaded externally.
Add `<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>` to your `index.html` or equivalent entry point, replacing `YOUR_API_KEY` with your actual Google API key.
Be aware that long-term support and rapid evolution of the library may depend on community contributions. Consider contributing if you rely heavily on this library.
Obtain an API key from Google Cloud Console, enable 'Places API' and 'Maps JavaScript API', and include it in your script tag: `key=YOUR_API_KEY`.
Ensure the Google Maps JavaScript API script is loaded synchronously in the `<head>` of your HTML with `defer` or `async` removed for initial load, or ensure it completes loading before your component mounts, as shown in the quickstart.
Add `&libraries=places` to your Google Maps script URL: `<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>`.
Verify your Google Cloud project's API key restrictions, ensure 'Places API' and 'Maps JavaScript API' are enabled, and check your billing account status.