React Native SDK
Use @perkamo/react-native for bare React Native 0.73+ and Expo apps. It ships the same provider and hooks as the React SDK plus a client tuned for mobile runtimes.
Install
bash
npm install @perkamo/react-nativeClient and provider
Mobile apps never bundle server API keys. Your backend exposes a token route — the same one described in the React SDK — and the app requests short-lived client tokens through getToken:
tsx
import {
createPerkamoReactNativeClient,
PerkamoProvider,
usePerkamoCustomerJson,
} from "@perkamo/react-native";
import { Text } from "react-native";
const perkamo = createPerkamoReactNativeClient({
getToken: async () => {
const response = await fetch("https://app.example.com/auth/perkamo/token", {
method: "POST",
headers: { authorization: `Bearer ${await getMySessionToken()}` },
});
const body = await response.json();
return body.token;
},
});
export function App() {
return (
<PerkamoProvider client={perkamo}>
<LoyaltyBadge />
</PerkamoProvider>
);
}
function LoyaltyBadge() {
const { customer, loading, error } = usePerkamoCustomerJson();
if (loading || error || !customer) return null;
return <Text>Level {customer.level.level}</Text>;
}Emit events
ts
await perkamo.emit("workout.completed", { minutes: 30 });Client events are validated against the token scope. Keep purchases, subscriptions and other business-critical events on your backend with a server SDK.
Live updates without EventSource
React Native has no EventSource, so subscribeCustomer — and the usePerkamoCustomerStream() hook — polls the customer endpoint instead of opening an SSE stream. The callback fires only when the customer actually changed. Tune the cadence with subscribePollIntervalMs (default 15000 ms, minimum 1000 ms):
ts
const perkamo = createPerkamoReactNativeClient({
getToken,
subscribePollIntervalMs: 30_000,
});No stream token is needed for polling; it reuses the regular client token. See Realtime streaming for how browser apps stream over SSE.
Security boundary
- Server API keys and signing secrets never ship inside the app bundle — app
binaries can be unpacked and inspected.
- The client accepts only
getToken; passing server-secret option names
throws at runtime.
- The client requires HTTPS API endpoints.
- Read Security and keys before shipping a mobile
integration.