Wrap Capacitor in capability hooks, not capability checks — and let the hooks lie to web on your behalf.
How ClearedMind keeps one React codebase honest across iOS, Android, and the browser without scattering platform checks.
The default Capacitor pattern looks like this:
if (Capacitor.isNativePlatform()) { await Haptics.impact({ style: ImpactStyle.Light }); }
Repeat that across a hundred components and you've effectively forked the codebase by attrition.
In ClearedMind, no feature code ever calls Capacitor.isNativePlatform(). Instead, every native capability is wrapped in a hook:
export function useHaptics() { return { impact: async (style: 'light' | 'medium' | 'heavy') => { if (!Capacitor.isNativePlatform()) return; await Haptics.impact({ style: mapStyle(style) }); }, }; }
A button just calls haptics.impact('light'). The hook decides whether that becomes a real Taptic Engine pulse, an Android vibration, or nothing at all on web.
If you're typing
isNativePlatformin feature code, you're missing a hook.