@aethex.os/mobile
v1.1.1
Published
AeThex mobile hooks — platform detection, haptics, camera, biometric auth, geolocation, network, filesystem, toast, and contacts for Capacitor apps
Maintainers
Readme
@aethex.os/mobile
React hooks for Capacitor mobile apps — platform detection, haptics, camera, biometric auth, geolocation, network status, filesystem, toast, and device contacts.
Install
npm install @aethex.os/mobileInstall the Capacitor plugins for the hooks you use:
npm install @capacitor/haptics @capacitor/camera @capacitor/geolocation \
@capacitor/network @capacitor/filesystem @capacitor/toast \
capacitor-native-biometric @capacitor-community/contactsPlatform Detection
import { isMobile, isDesktop, isWeb, detectPlatform } from '@aethex.os/mobile';
detectPlatform(); // 'mobile' | 'desktop' | 'web'
isMobile(); // true on Capacitor iOS/AndroidHooks
useHaptics
const { impact, notification, vibrate } = useHaptics();
await impact('medium'); // light | medium | heavy
await notification('success'); // success | warning | error
await vibrate(50); // ms, falls back to navigator.vibrateuseDeviceCamera
const { takePhoto, pickPhoto, photo } = useDeviceCamera();
const result = await takePhoto();
// result.webPath, result.path, result.formatuseBiometricAuth
const { isAvailable, biometricType, authenticate } = useBiometricAuth();
// biometricType: 'fingerprint' | 'face' | 'iris' | 'none'
const ok = await authenticate('Confirm your identity');useGeolocation
const { position, getCurrentPosition, startWatching } = useGeolocation();
const pos = await getCurrentPosition();
// pos.coords.latitude, pos.coords.longitude, pos.coords.accuracyuseNetwork
const { connected, connectionType } = useNetwork();
// connectionType: 'wifi' | 'cellular' | '4g' | 'unknown' | ...useFilesystem
const { writeFile, readFile, listFiles } = useFilesystem();
await writeFile('notes.txt', 'hello');
const content = await readFile('notes.txt');useToast
const { show } = useToast();
await show('Saved!', 'short', 'bottom');useDeviceContacts
const { fetchContacts, contacts } = useDeviceContacts();
await fetchContacts();
// contacts[0].displayName, .phoneNumbers, .emailsPart of the @aethex.os ecosystem
See @aethex.os/core for the full package list.
