Skip to Content

Regional Logic

Housr operates in two regions: United Kingdom (UK) and United States (US). Each repo handles regional differences in its own way.

Housr-App (Mobile)

Regional behavior is controlled by a build-time environment variable:

  • EXPO_PUBLIC_USA_MODE (true or false) in .env
  • Exported as isUsaMode from src/config/env.ts
  • Separate EAS build profiles: uk-staging, us-staging, uk-production, us-production

What changes between regions:

  • Different API base URLs
  • Bills feature is hidden in US mode
  • Different sign-in methods available
  • Different feature flags
  • Different content and copy

Code typically checks isUsaMode to conditionally render features or call different endpoints.

Housr-Webapp (Next.js)

The Webapp uses locale-based routing to serve both regions from a single deployment.

Routing:

  • Pages live under src/app/[locale]/ where locale is us or uk
  • next.config.ts rewrites: / redirects to /us, unmatched paths default to /us/:path*
  • No middleware.ts — rewrites handle locale detection

Route restrictions:

  • Each route has an allowedRegions config in src/components/layouts/route-config.tsx
  • SmartHeaderLayout enforces region restrictions and redirects users away from region-locked pages

Dictionaries:

  • src/dictionaries/us.json and uk.json provide region-specific text
  • Loaded server-side via getDictionary(locale)
  • Passed as props through the component tree

Client components:

  • Use getCurrentLocale(pathname) from src/lib/utils/locale.ts to determine the current region
  • Use getLocaleAwareHref(href, locale) to build links that preserve the current locale

API v1

  • Uses a $USA global flag to switch behavior
  • Region affects data filtering, available endpoints, and business logic
  • Set via environment configuration

API v2

  • Region-based middleware and configuration
  • Modules can define region-specific behavior
  • Region is typically passed as a parameter or determined from the authenticated user’s context

Housr Portal

  • Multi-region data — the Portal can manage both UK and US properties, users, and operations
  • Filament resources include region filters
  • Admin users may have region-specific access restrictions

Adding Region-Specific Features

When building a feature that behaves differently per region:

  1. App: Check isUsaMode and conditionally render/route. Use feature flags for gradual rollout.
  2. Webapp: Use the allowedRegions config in route-config.tsx to restrict pages. Use dictionaries for text differences.
  3. API v2: Add region-aware logic in the module. Accept region as a parameter or derive from user context.
  4. Portal: Add region filters to Filament resources. Ensure admin users can manage both regions.
Last updated on