A Nuxt module to fetch and display user country information.
- 🌍 Fetch user country information from JAMflow free API.
- 🌐 Display user country ISO and Full Name.
- 🗺️ Supports 250 countries, autonomous regions, ...
- ⚡ Extremely fast detection and response time.
Install the module to your Nuxt application with one command:
npx nuxi module add user-country-module
That's it! You can now use the User Country Module in your Nuxt app ✨
The useUserCountry
composable fetches the user's country information based on their IP address.
<template>
<div>
<p>{{ status }}</p>
<p v-if="status === 'success'">Your country is: {{ data.name }}</p>
<p v-if="status === 'error'">Error: {{ data }}</p>
<button @click="refresh">Refresh</button>
</div>
</template>
<script setup>
const { data, refresh, status } = await useUserCountry();
</script>
data
: The country information object containingname
andiso
.refresh
: Function to refresh the country information.status
: The status of the fetch request ('idle'
,'loading'
,'success'
,'error'
).
When compared to other free alternatives, this module stands out because:
- Focuses on performance: With an average global latency of just 25ms, it's one of the fastest options available.
- Effective localization suggestions: It works well to suggest changing the user's country or language/currency based on their location, making it ideal for enhancing the user experience.
- No browser location sharing required: Unlike some other solutions, it doesn't require the user to share their precise browser location, ensuring better privacy while still delivering accurate information.
The module bases its detection on a network of 119 PoP, with an average global latency of 25ms. The API is offered by JAMflow.cloud and is free to use, without any guarantee currently. We will limit IP or website that will spam or abuse the service.
You are allowed to use the service for any commercial use, but you are not allowed to resell it without an agreement with us beforehand.
We limit requests to 3 requests per second per IP address. If you need a higher rate limit, please contact us.
Local development
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release