Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-google-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-autocomplete

React component for google autocomplete.

  • 2.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
155K
increased by1.55%
Maintainers
1
Weekly downloads
 
Created

What is react-google-autocomplete?

The react-google-autocomplete package is a React component that provides an easy way to integrate Google Places Autocomplete into your React applications. It allows users to search for and select location-based suggestions, which can be used for various purposes such as filling out address forms, location-based searches, and more.

What are react-google-autocomplete's main functionalities?

Basic Autocomplete

This feature allows you to integrate a basic Google Places Autocomplete input field into your React application. When a user selects a place, the place details are logged to the console.

import React from 'react';
import ReactGoogleAutocomplete from 'react-google-autocomplete';

function App() {
  return (
    <div>
      <h1>Google Autocomplete Example</h1>
      <ReactGoogleAutocomplete
        apiKey="YOUR_GOOGLE_API_KEY"
        onPlaceSelected={(place) => {
          console.log(place);
        }}
      />
    </div>
  );
}

export default App;

Restricting Search to Specific Types

This feature allows you to restrict the autocomplete suggestions to specific types, such as regions. This can be useful if you want to limit the search to certain categories of places.

import React from 'react';
import ReactGoogleAutocomplete from 'react-google-autocomplete';

function App() {
  return (
    <div>
      <h1>Google Autocomplete with Type Restriction</h1>
      <ReactGoogleAutocomplete
        apiKey="YOUR_GOOGLE_API_KEY"
        types={['(regions)']}
        onPlaceSelected={(place) => {
          console.log(place);
        }}
      />
    </div>
  );
}

export default App;

Restricting Search to Specific Countries

This feature allows you to restrict the autocomplete suggestions to a specific country. This can be useful if your application is targeted towards users in a particular country.

import React from 'react';
import ReactGoogleAutocomplete from 'react-google-autocomplete';

function App() {
  return (
    <div>
      <h1>Google Autocomplete with Country Restriction</h1>
      <ReactGoogleAutocomplete
        apiKey="YOUR_GOOGLE_API_KEY"
        componentRestrictions={{ country: 'us' }}
        onPlaceSelected={(place) => {
          console.log(place);
        }}
      />
    </div>
  );
}

export default App;

Other packages similar to react-google-autocomplete

Keywords

FAQs

Package last updated on 24 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc