Add analytics to React Native.
React Native analytics means capturing navigation and taps across iOS and Android from your JS bundle. smolanalytics ships no React Native SDK. You send events with fetch to /v1/events, the same call your web and backend use. Batch them to save battery, then ask your numbers in plain English from the dashboard or your editor.
const host = 'https://YOUR-INSTANCE';
const key = 'WRITE_KEY';
export function track(name: string, distinctId: string, properties: Record<string, unknown> = {}) {
return fetch(`${host}/v1/events`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
body: JSON.stringify({ name, distinct_id: distinctId, properties }),
});
}
// batch: POST an array to the same endpoint
// fetch(`${host}/v1/events`, { method: 'POST', headers, body: JSON.stringify([e1, e2, e3]) });No RN SDK and the browser sdk.js does not run here (no DOM). Use plain fetch, which is built in, and call track from your navigation listener and handlers.
how do I add analytics to react native?
React Native analytics means capturing navigation and taps across iOS and Android from your JS bundle. smolanalytics ships no React Native SDK. You send events with fetch to /v1/events, the same call your web and backend use. Batch them to save battery, then ask your numbers in plain English from the dashboard or your editor.
Hook track() into React Navigation's onStateChange or a screen listener so each screen fires a screen_view event with the route name, and call it on the taps that matter (signup, purchase, share). Pass a stable distinct_id, your user id once they log in, a device or install id before that, so a single person threads across screens and sessions.
On mobile you want fewer requests. Push events into an array and flush a batched JSON POST to /v1/events on an interval or when the app goes to background with AppState. It is the exact endpoint the smolanalytics web SDK and your server hit, so everything lands in one place and you can ask, in plain English, which flow leaks users.
Honest pricing: 14-day full trial, no credit card. Then Solo $29/mo, never metered on seats or sites. Overage is $5/million with an emailed receipt, the dashboard never locks, and self-hosting the single Go binary is free forever (MIT).
Add analytics to React Native tonight.
One snippet, or one endpoint. Tomorrow morning the verdict tells you which part of the funnel to fix.