TypeScript icon, indicating that this package has built-in type declarations

2.17.1-alpha • Public • Published



npm package npm downloads npm bundle size Join the community on Spectrum DeepScan grade


You can donate or became a sponsor of the project here: https://opencollective.com/react-google-maps-api#category-CONTRIBUTE

This library requires React v16.6 or later. To use the latest features (including hooks) requires React v16.8+. If you need support for earlier versions of React, you should check out react-google-maps

This is complete re-write of the (sadly unmaintained) react-google-maps library. We thank tomchentw for his great work that made possible.

@react-google-maps/api provides very simple bindings to the google maps api and lets you use it in your app as React components.

Here are the main additions to react-google-maps that were the motivation behind this re-write

Install @react-google-maps/api

with NPM

npm i -S @react-google-maps/api

or Yarn

yarn add @react-google-maps/api
import React from 'react'
import { GoogleMap, useJsApiLoader } from '@react-google-maps/api';

const containerStyle = {
  width: '400px',
  height: '400px'

const center = {
  lat: -3.745,
  lng: -38.523

function MyComponent() {
  const { isLoaded } = useJsApiLoader({
    id: 'google-map-script',
    googleMapsApiKey: "YOUR_API_KEY"

  const [map, setMap] = React.useState(null)

  const onLoad = React.useCallback(function callback(map) {
    // This is just an example of getting and using the map instance!!! don't just blindly copy!
    const bounds = new window.google.maps.LatLngBounds(center);

  }, [])

  const onUnmount = React.useCallback(function callback(map) {
  }, [])

  return isLoaded ? (
        { /* Child components, such as markers, info windows, etc. */ }
  ) : <></>

export default React.memo(MyComponent)

Migration from react-google-maps@9.4.5

if you need an access to map object, instead of ref prop, you need to use onLoad callback on <GoogleMap /> component.


// before - don't do this!
  ref={map => {
    const bounds = new window.google.maps.LatLngBounds();



  onLoad={map => {
    const bounds = new window.google.maps.LatLngBounds();
  onUnmount={map => {
    // do your stuff before map is unmounted

If you want to use window.google object, you need to extract GoogleMap in separate module, so it is lazy executed then google-maps-api script is loaded and executed by <LoadScript />. If you try to use window.google before it is loaded it will be undefined and you'll get a TypeError.

Main features

  • Simplified API
  • Uses the new Context API
  • Supports async React (StrictMode compliant)
  • Removes lodash dependency => smaller bundle size 12.4kb gzip, tree-shakeable https://bundlephobia.com/result?p=@react-google-maps/api
  • forbids loading of Roboto fonts, if you set property preventGoogleFonts on <LoadScript preventGoogleFonts /> component


Examples can be found in two places:

  1. Official docs (powered by react-styleguidist.
  2. A Gatsby app including some examples. See the examples folder
  3. Gatsby.js Demo


Using the examples requires you to generate a google maps api key. For instructions on how to do that please see the following guide

Community Help Resource

You can join the community at Spectrum.chat to ask questions and help others with your experience or join our Slack channel


Maintainers and contributors are very welcome! See this issue to get started.

How to test changes locally

When working on a feature/fix, you're probably gonna want to test your changes. This workflow is a work in progress. Please feel free to improve it!

  1. In the file packages/react-google-maps-api/package.json change main to "src/index.ts"
  2. In the same file, delete the module field
  3. You can now use the package react-google-maps-api-gatsby-example to test your changes. Just make sure you change the import from @react-google-maps/api to ../../../react-google-maps-api

Since 1.2.0 you can use onLoad and onMount props for each @react-google-maps/api component, ref does not contain API methods anymore.

Since version 1.2.2 We added useGoogleMap hook, which is working only with React@16.8.1 and later versions.

Websites made with @react-google-maps-api

DriveFromTo.com Transfer Booking service PWA.

Shipwrecks.cc Shipwrecks from Wikipedia visualized on the map (Github)

nycmesh.net Network topography visualized on the map (Github)

add your website by making PR!

Package Sidebar


npm i @luxuryescapes/react-google-maps-api

Weekly Downloads






Unpacked Size

6.4 MB

Total Files


Last publish


  • gabrielgsduarte
  • adisembiringle
  • gearoid-sheehan
  • finbar-kelly-le
  • maha-zohbi-le
  • chrisnassif
  • yangbole
  • ron-crisostomo-le
  • afabbiani
  • georgia-wahib-le
  • jeanbiezus
  • elias.vieira
  • roberto-luxuryescapes
  • ethanscavia
  • jahanzeb-hussain-le
  • lukejudd-lux
  • chiamaka-ibeme-le
  • vincent-tran-le
  • welingtonlarsenlux
  • hfrankel
  • sangin.lee
  • tuanhung-pham-le
  • lukas-zimmermann-le
  • lux-alexd
  • william.idoine
  • edward.iskenderian
  • adham-oliveira
  • james-kwok-le
  • aleksandar.vuksanovic
  • nishanthi.n
  • glesage_le
  • daviaazevedo
  • william-ong
  • philippecarvalho
  • dulaj.pathirana
  • hamed.le
  • samhammond
  • paulo.silva3991
  • noahxny
  • dishang
  • ahmad.hafez
  • jordikitto_le
  • steve.dang
  • andrewjohnstone
  • brunohaveroth
  • pavel-lux
  • mary-le
  • pankaj-le
  • gabe-miranda-lux
  • thilina-piyadasun-le
  • gabriel.costa.lux
  • harish-indla-le
  • eran.stiller.luxury.escapes
  • sakethgetla
  • nicholaspuglia
  • sitaraman
  • siddharth.bose
  • aarontoomey-le
  • sergio.costa.luxuryescapes
  • matthewdelaneyatluxuryescapes
  • ricardobalbinot
  • callmekev
  • semeer-acheerithodi-le
  • andrey-tryapitsin-le
  • quan.tang
  • alexander.yakovenko
  • greg-cumming-le
  • jerry.huang-le
  • dan-wanigasekera-le
  • dunedayl
  • arminmon-le
  • mattswansonlux
  • cleberricardi
  • felipefeal.lux
  • tracymu
  • chris.nguyen.lux
  • marhalpert
  • reb2020
  • zediah
  • sonyque
  • joshuacullenlux
  • shawn-cx-li
  • colins44
  • diegogadens
  • felixivanov
  • joshua.paling.le
  • operations.luxgroup
  • eddiemcleanlux
  • robert.harris.lux
  • kostya-luxuryescapes
  • alexb.pi
  • kaustuva
  • luizcarraro
  • ryan.tian
  • le_tyang
  • richardbiddle
  • henryshen-le
  • jamesly