crosshooks
Typed React hooks for device features that normally behave differently on web, iOS, and Android. Each hook exposes one consistent API, so the same component can run everywhere without branching on the platform.
Install
Requires React 16.8 or newer. Provider SDKs are optional and only installed when you choose that provider.
# if you use npm
npm install @zoharyandrianome/crosshooks
# if you use pnpm
pnpm add @zoharyandrianome/crosshooksWhy crosshooks
One API, every platform
Write a feature once and reuse it across web and React Native. The return shape stays identical, so shared UI never has to know where it runs.
Fully typed
Every hook ships with TypeScript definitions, so states, options, and return values are checked as you write them.
Standards first
Browser features use native web platform APIs with no runtime dependencies. Optional provider adapters are only pulled in when you reach for them.
Safe where unsupported
On platforms that lack a capability, a hook returns a quiet no-op state you can read through isSupported and hide the related UI.
The hooks
usePWAInstallPromptWebDrives the browser's “Add to Home Screen” flow so you can offer an install button at the right moment, know when the app is already installed, and read the user's choice after the prompt.
PWA install guide →usePushNotificationsWeb & nativeRegisters a device for push notifications and hands you the subscription to store on your backend. Standards-based Web Push works out of the box; native iOS and Android delivery is enabled through an optional provider adapter.
useOfflineSyncWeb & nativeA persistent, connectivity-aware queue for mutations made while offline. Writes are stored as they happen and drained through your onSync handler when the device reconnects, with order-preserving retries.