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

vue-google-maps-loader

v2.1.5

Published

A Vue 3 composable for loading the Google Maps JavaScript API with reactive locale switching.

Readme

vue-google-maps-loader

NPM Version NPM License NPM Downloads

A Vue 3 composable for loading the Google Maps JavaScript API with reactive locale switching.

✨ Features

  • Built on the official @googlemaps/js-api-loader
  • Vue 3 Composition API ready
  • Works seamlessly with vue3-google-map via the :api-promise prop
  • Cleans up injected scripts, links, and styles
  • Automatically reloads Maps API when the locale changes

🤔 Why use this?

The official @googlemaps/js-api-loader doesn't support:

  • Locale switching - Can't reload the API with a different language at runtime
  • Vue reactivity - No integration with Vue's reactive system

This composable solves these issues by wrapping the loader with Vue 3 reactivity and handling dynamic reloads.

🚀 Installation

npm install vue-google-maps-loader

📖 API

useGoogleMapsLoader(apiOptions: APIOptions, locale: Ref<string>): {
  isAvailable: Ref<boolean>;
  apiPromise: Ref<Promise<typeof google>>;
}
  • apiOptions — Options passed to @googlemaps/js-api-loader (e.g. key, libraries, version). See the full list of options. Defaults libraries to ['core'] if not specified.
  • locale — Any reactive Ref<string> with a BCP 47 language tag. The Maps API reloads automatically when this value changes.
  • isAvailablefalse while the API is loading or reloading, true when ready.
  • apiPromise — Resolves to the google global once the API is loaded. Updates on each reload.

Note: useGoogleMapsLoader is a singleton. Only the first call initializes the loader — subsequent calls return the same instance regardless of the arguments passed. Call it once at the app or plugin level and use the returned refs anywhere in your app.

⚡ Usage

With vue3-google-map

<script setup>
import { useI18n } from 'vue-i18n';
import { GoogleMap } from 'vue3-google-map';
import { useGoogleMapsLoader } from 'vue-google-maps-loader';

const { locale } = useI18n();

const apiOptions = { key: import.meta.env.VITE_GOOGLE_API_KEY };

const { isAvailable, apiPromise } = useGoogleMapsLoader(apiOptions, locale);
</script>

<template>
	<GoogleMap
		v-if="isAvailable"
		:api-promise
		:center="{ lat: 38.725282, lng: -9.149996 }"
		:zoom="12"
		style="width: 100%; height: 500px"
	/>
</template>

Standalone

<script setup>
import { useTemplateRef, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useGoogleMapsLoader } from 'vue-google-maps-loader';

const { locale } = useI18n();

const apiOptions = { key: import.meta.env.VITE_GOOGLE_API_KEY };

const { isAvailable, apiPromise } = useGoogleMapsLoader(apiOptions, locale);

const mapElement = useTemplateRef('map-element');

watch(
	isAvailable,
	async (available) => {
		if (!available) return;

		const google = await apiPromise.value;

		new google.maps.Map(mapElement.value, {
			center: { lat: 38.725282, lng: -9.149996 },
			zoom: 12,
		});
	},
	{ immediate: true },
);
</script>

<template>
	<div
		ref="map-element"
		style="width: 100%; height: 500px"
	/>
</template>

locale can be any Ref<string> — this example uses vue-i18n, but any reactive ref works.

⚠️ Disclaimer

  • Unofficial reload technique — Reloading the Maps API works by manually removing Google's injected scripts, stylesheets, and styles from the DOM and deleting window.google.maps. This relies on internal implementation details that are not part of the Google Maps JavaScript API and are not guaranteed to remain stable across future updates.

  • Incompatible with Google Maps Web Components — This loader cannot be used alongside Google Maps Web Components (e.g. <gmp-map>), because custom elements cannot be unregistered once defined, making the reload strategy ineffective in those environments.