Skip to content

A react hook wrapper for the google maps location autocomplete api.

Notifications You must be signed in to change notification settings

JorgenHookham/google-autocomplete-react-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Autocomplete React Hook

A react hook wrapper for the google maps location autocomplete api. See also Google's places autocomplete docs.

Installation

npm i google-autocomplete-react-hook
yarn add google-autocomplete-react-hook

Usage

The hook accepts an API key and will return a function that you can use to make autocompletion requests to Google's API.

The returned function accepts an AutocompletionRequest and returns a promise-wrapped list of AutocompletePrediction.

Basic Example

import useGoogleLocationAutocomplete from "google-autocomplete-react-hook";

const MyComponent: React.FC = () => {
  const locationAutocomplete = useGoogleLocationAutocomplete("mygoogleapikey");
  locationAutocomplete({input: "Calif"}).then(console.log);
}

Tests

npm run test

About

A react hook wrapper for the google maps location autocomplete api.

Resources

Stars

Watchers

Forks

Packages