npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-google-places-v1-autocomplete

v1.0.1

Published

Customizable and typed React component for Google Places Autocomplete using v1 API

Readme

React Google Places Autocomplete (v1 API) for React

A reusable, customizable, and accessible React component for Google Places Autocomplete using the Places API v1.

Ideal for address inputs where you need detailed location metadata, this package supports error handling, loading states, keyboard navigation, and custom renderers.


Demo

✨ Features

  • Fully typed with TypeScript
  • Debounced input handling
  • Custom render support for suggestions
  • Async place detail fetching
  • Loading state with custom UI
  • Keyboard navigation support (⬆️⬇️ coming soon)
  • Accessibility attributes (aria-*)
  • Clean fallback error handling with onError

🚀 Installation

npm install react-google-places-v1-autocomplete

⚙️ Usage

import { GooglePlacesAutocomplete } from "react-google-places-v1-autocomplete";

<GooglePlacesAutocomplete
  apiKey="YOUR_GOOGLE_MAPS_API_KEY"
  onSelect={(place) => console.log(place)}
  onError={(error) => console.error(error)}
  debounceDelay={300}
  placeholder="Search for a place..."
  customLoader={<div>Loading suggestions...</div>}
  renderSuggestion={(suggestion) => (
    <strong>{suggestion.text.text}</strong>
  )}
/>

📊 Props

| Prop | Type | Required | Default | Description | | ------------------ | --------------------------------------------- | -------- | --------------------- | ---------------------------------------- | | apiKey | string | Yes | – | Your Google Places API key. | | onSelect | (place: PlaceDetails) => void | Yes | – | Callback fired when a place is selected. | | onError | (error: unknown) => void | No | – | Callback fired when API request fails. | | placeholder | string | No | "Search address..." | Placeholder for the input. | | label | string | No | – | Optional label (not currently rendered). | | className | string | No | "" | Custom class for the wrapper container. | | debounceDelay | number | Yes | 500 | Delay in ms to debounce input. | | customLoader | React.ReactNode | Yes | "loading..." | UI to show while fetching suggestions. | | renderSuggestion | (suggestion: Suggestion) => React.ReactNode | No | Default text renderer | Custom UI for suggestion item. |


📋 PlaceDetails Object Structure

The onSelect callback returns a PlaceDetails object:

interface PlaceDetails {
  name: string;
  lat: number;
  lng: number;
  placeId: string;
  id: string;
  types: string[];
  formattedAddress: string;
  location: {
    latitude: number;
    longitude: number;
  };
  viewport: {
    low: { latitude: number; longitude: number; };
    high: { latitude: number; longitude: number; };
  };
  googleMapsUri: string;
  displayName: {
    text: string;
    languageCode: string;
  };
}

🚨 Notes / Requirements

Required from you:

  • A valid Google Cloud Platform API key with Places API enabled.
  • Billing must be enabled for your GCP project.
  • Add your API key in the apiKey prop.
  • (Optional but Recommended) Secure your API key with HTTP referrer restrictions.

Potential TODOs (can be improved):


✨ Styling

No default styles are enforced except basic inline layout. You can apply your own styling using the className prop and by targeting internal class hooks like:

  • .new_place_select_input
  • .new_place_select_dropdown

🎓 License

MIT License. Free for personal and commercial use.


🙌 Contributions

Feel free to suggest features or create pull requests. If you're interested in contributing, drop a message!