> For the complete documentation index, see [llms.txt](https://docs.onside.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onside.io/sdk/products-and-subscriptions/regions-and-storefronts.md).

# Regions & Storefronts

Product availability and pricing vary by region. OnsideKit resolves a region for every products request and exposes the authenticated region as the **storefront**.

## How the region is resolved

### When logged in

The region is the **account's region** — the most accurate source of truth. It is exposed as `Onside.defaultPaymentQueue().storefront?.countryCode`. Once the user is logged in, this always wins; a pre-login hint (below) is ignored.

### When logged out

OnsideKit estimates the region:

1. The `onsideDefaultCountryCodeAssumption()` delegate hint, if you provide one.
2. Otherwise, the device's system region.

```swift
extension AppDelegate: OnsideDelegate {
    func onsideDefaultCountryCodeAssumption() -> String? {
        // An ISO 3166-1 alpha-2 code, e.g. "US", "DE", "GB".
        return userKnownRegion   // or nil to fall back to the device region
    }
}
```

{% hint style="info" %}
`onsideDefaultCountryCodeAssumption()` is the only hook that influences the region, and only **before** login. Provide it when your app already knows the user's likely region (from their profile or settings) so logged-out pricing is accurate. See [The Onside Delegate](/sdk/customization/delegate.md).
{% endhint %}

## The storefront

```swift
struct OnsideStorefront {
    var id: String
    var countryCode: String
}
```

`Onside.defaultPaymentQueue().storefront` is `nil` until the user logs in, then reflects the account's region. It changes when the user logs in or out, or their region changes.

## Best practice: fetch before login, then re-fetch

You can and should [fetch products](/sdk/products-and-subscriptions/fetching-products.md) before the user authenticates, so your store UI is ready immediately. Because the true region is only known after login, **re-fetch your products whenever the storefront changes**.

Observe the storefront with a transaction observer:

```swift
func onsidePaymentQueueDidChangeStorefront(_ queue: OnsidePaymentQueue) {
    // The region may have changed — refresh prices/availability.
    reloadProducts()
}
```

See [Authentication & User Account](/sdk/core-concepts/authentication.md) for the full observer setup.

## Purchase protection on region change

If a user starts a purchase for a product fetched in one region but their account turns out to be in another, OnsideKit does **not** silently charge the new price. The queued purchase is gated so you can confirm the change with the user or cancel it. This is handled by the payment queue delegate — see [Handling Storefront & Price Changes](/sdk/purchasing/storefront-price-changes.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onside.io/sdk/products-and-subscriptions/regions-and-storefronts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
