@fivexer/expo
v0.1.0
Published
Worker-facing Expo/React Native SDK for the Fivexer Platform: secure session persistence, live queue WebSocket, React hooks, push, and geo
Readme
@fivexer/expo
Worker-facing Expo / React Native SDK for the Fivexer Platform.
The base @fivexer/sdk already works in
Expo because it is zero-dependency and only needs fetch. This package adds the
mobile-specific glue every worker app needs:
- SecureStore-backed
wt_session persistence (PIN login, resume, logout) - Typed, reconnecting WebSocket client for live queue pushes
- React hooks (
useWorkerSession,useQueue,useTaskDetail, ...) - Expo push token registration
- Foreground location updates for geo-constrained task matching
Scope: worker portal plane only. This package never exposes the workspace
sk_ key — do not embed admin keys in a mobile app.
Install
npx expo install @fivexer/expo @fivexer/sdk expo-secure-store expo-notifications expo-location expo-constants reactQuickstart
import { FivexerWorkerProvider, ExpoFivexerWorker, useWorkerSession, useQueue } from '@fivexer/expo';
const worker = new ExpoFivexerWorker({ baseUrl: 'https://api.5xer.com' });
function App() {
return (
<FivexerWorkerProvider worker={worker}>
<WorkerScreen />
</FivexerWorkerProvider>
);
}
function WorkerScreen() {
const { session, login, logout, loading } = useWorkerSession();
const { taskIds } = useQueue();
if (loading) return <Text>Resuming…</Text>;
if (!session) {
return <Button title="Log in" onPress={() => login({ workspaceId: 'ws_...', workerId: 'w_...', pin: '1234' })} />;
}
return (
<View>
<Text>Hello, {session.workerId}</Text>
<Text>Queue: {taskIds.length} tasks</Text>
<Button title="Log out" onPress={logout} />
</View>
);
}Push notifications
import { registerForPushNotificationsAsync } from '@fivexer/expo';
async function enablePush(worker: ExpoFivexerWorker) {
const registration = await registerForPushNotificationsAsync(worker);
if (!registration) return; // permission denied
// registration.unregister() when the worker logs out
}Location updates
import { startLocationUpdatesAsync } from '@fivexer/expo';
async function enableLocation(worker: ExpoFivexerWorker) {
const { remove } = await startLocationUpdatesAsync(worker, { intervalMs: 30_000 });
// remove() when done
}Realtime status
useWorkerSession() returns status: 'closed' | 'connecting' | 'open'. The
provider automatically connects the WebSocket when a session exists and the app
is in the foreground, and pauses it in the background.
Security
sk_workspace API keys must never ship inside a mobile app.- Store the worker
wt_token inexpo-secure-store(default) or your ownSecureStoreBackend. - Logout revokes the server session, clears all registered push tokens, and wipes local storage.
