Skip to main content

useApiIsLoaded Hook

React hook to check if the Maps JavaScript API has finished loading.

import {useApiIsLoaded} from '';

const MyComponent = () => {
const apiIsLoaded = useApiIsLoaded();

useEffect(() => {
if (!apiIsLoaded) return;

// when the maps library is loaded, apiIsLoaded will be true and the API can be
// accessed using the global `google.maps` namespace.
}, [apiIsLoaded]);

// ...


useApiIsLoaded(): boolean

Returns a boolean indicating if the Maps JavaScript API completed loading.