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(trueorfalse) in.env- Exported as
isUsaModefromsrc/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 isusoruk next.config.tsrewrites:/redirects to/us, unmatched paths default to/us/:path*- No
middleware.ts— rewrites handle locale detection
Route restrictions:
- Each route has an
allowedRegionsconfig insrc/components/layouts/route-config.tsx SmartHeaderLayoutenforces region restrictions and redirects users away from region-locked pages
Dictionaries:
src/dictionaries/us.jsonanduk.jsonprovide region-specific text- Loaded server-side via
getDictionary(locale) - Passed as props through the component tree
Client components:
- Use
getCurrentLocale(pathname)fromsrc/lib/utils/locale.tsto determine the current region - Use
getLocaleAwareHref(href, locale)to build links that preserve the current locale
API v1
- Uses a
$USAglobal 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:
- App: Check
isUsaModeand conditionally render/route. Use feature flags for gradual rollout. - Webapp: Use the
allowedRegionsconfig inroute-config.tsxto restrict pages. Use dictionaries for text differences. - API v2: Add region-aware logic in the module. Accept region as a parameter or derive from user context.
- Portal: Add region filters to Filament resources. Ensure admin users can manage both regions.
Last updated on