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

react-native-nitro-store-country

v1.0.0

Published

Get the user's App Store (iOS) or Google Play (Android) country code with a single call. Built with Nitro for maximum performance.

Readme

react-native-nitro-store-country

⚡️ Lightning-fast store country detection for React Native using Nitro Modules

Get the user's App Store (iOS) or Google Play (Android) country code with a single call. Built with Nitro for maximum performance.

Features

  • ⚡️ Lightning-fast - Built with Nitro Modules for maximum performance
  • 🎯 Accurate - Gets store country from StoreKit (iOS) and Google Play Billing (Android)
  • 💾 Fetch once - Queries store APIs once and saves the result
  • 🔄 Force refresh - Option to refetch when needed
  • 📱 System country - Access device locale country when store country is unavailable
  • 🍎 [iOS] Auto-fallback - Automatically uses system country for non-App Store builds (TestFlight returns "USA")
  • 🍎 [iOS] Alpha-2 codes - Converts StoreKit's alpha-3 codes to alpha-2 format
  • TypeScript - Full type safety out of the box
  • 🎨 Simple API - Just one method and one property

Installation

npm install react-native-nitro-store-country react-native-nitro-modules
yarn add react-native-nitro-store-country react-native-nitro-modules
bun add react-native-nitro-store-country react-native-nitro-modules

iOS

cd ios && pod install

Android

No additional steps required. The library uses autolinking.

Expo

Works with Expo Development Builds via EAS:

npx expo install react-native-nitro-store-country react-native-nitro-modules
eas build --profile development

Note: Not compatible with Expo Go (requires native code).

Usage

Basic Usage

import { StoreCountry } from 'react-native-nitro-store-country'

// Get store country (saves result after first call)
const storeCountry = await StoreCountry.getStoreCountry()
console.log(storeCountry) // "US", "GB", "DE", etc. or undefined

// Get device/system country (synchronous)
const systemCountry = StoreCountry.systemCountry
console.log(systemCountry) // "US", "GB", "DE", etc.

Force Refresh

// Force refetch when needed
const freshCountry = await StoreCountry.getStoreCountry(true)

React Hook Example

import { useEffect, useState } from 'react'
import { StoreCountry } from 'react-native-nitro-store-country'

const useStoreCountry = () => {
  const [country, setCountry] = useState(StoreCountry.systemCountry)

  useEffect(() => {
    StoreCountry.getStoreCountry().then(result => {
      // Update to store country if available, otherwise keep system country
      if (result !== undefined) {
        setCountry(result)
      }
    })
  }, [])

  return country
}

const App = () => {
  const country = useStoreCountry()

  return (
    <View>
      <Text>Country: {country ?? 'Unknown'}</Text>
    </View>
  )
}

API Reference

getStoreCountry(force?: boolean): Promise<string | undefined>

Gets the user's store country code (ISO 3166-1 alpha-2).

Parameters:

  • force (optional): If true, forces a fresh fetch from the store API, ignoring any previously saved result. Default: false

Returns:

  • Promise<string | undefined> - Two-letter country code (e.g., "US", "GB") or undefined if unavailable

Behavior:

  • First call: Fetches from native store API (StoreKit/Google Play Billing)
  • Subsequent calls: Returns saved result
  • Saves undefined results to avoid repeated failed API calls
  • Pass force: true to ignore saved result

systemCountry: string | undefined

The device's system locale country (synchronous, readonly).

Returns:

  • string | undefined - Two-letter country code from device locale settings

Source:

  • iOS: Locale.current.region?.identifier
  • Android: Locale.getDefault().country

Platform-Specific Notes

iOS

  • App Store builds: Returns accurate store country from StoreKit
  • TestFlight/Debug/Simulator: Automatically falls back to systemCountry (StoreKit returns "USA" in these environments, so the library uses system locale instead)
  • Alpha-3 to Alpha-2 conversion: Converts StoreKit's 3-letter country codes (e.g., "USA") to 2-letter ISO 3166-1 alpha-2 codes (e.g., "US") to match systemCountry format
  • Automatic fallback: Only happens on iOS for non-App Store builds. On App Store, returns StoreKit's value directly

Android

  • Uses Google Play Billing Library to fetch store country
  • Returns undefined if:
    • Device doesn't have Google Play Services
    • User is not signed into Google Play
    • Billing client connection fails

Contributing

See the contributing guide to learn how to contribute to the repository.

License

MIT


Made with ❤️ using Nitro Modules