viakite
Dashboard

Guides/Use cases/Mobile apps

Mobile apps

Screens, events and users from React Native

You ship an iOS and Android app in React Native, with Expo or without. You want screens, actions and signed-in users in the same place as your website's numbers, and events that survive the app going offline or being closed.

Who it's for

Mobile teams building with React Native.

What you get

FeatureWhat it doesGuide
@viakite/react-nativeScreens as page views, custom events, identify and reset, for Expo and bare appsReact Native
React Navigation and Expo RouterEvery screen sent as the user movesScreens
Offline queueEvents kept on the device and sent later, retried with backoffSending, offline and retries
Users, funnels and retentionPeople followed across app starts and devices by your user idRetention
RevenueIn-app purchases with revenue and currencyRevenue

Set it up

  1. Install the SDK

    terminal
    1npx expo install @viakite/react-native @react-native-async-storage/async-storage
    terminal
    1npm install @viakite/react-native @react-native-async-storage/async-storage

    It needs React Native 0.70 or later. In a bare app, run npx pod-install for iOS.

  2. Start it and send screens

    Copy the public key from Analytics → Install. With Expo Router, in the root layout:

    app/_layout.tsx
    1import { useEffect } from "react";
    2import { Stack, usePathname } from "expo-router";
    3import { init, screen } from "@viakite/react-native";
    4
    5init({ project: process.env.EXPO_PUBLIC_VIAKITE_KEY! });
    6
    7export default function Layout() {
    8 const pathname = usePathname();
    9 useEffect(() => screen(pathname), [pathname]);
    10 return <Stack />;
    11}

    With React Navigation, call trackNavigation(ref) from the container's onReady instead; see React Navigation.

  3. Identify users and send events

    src/auth.ts
    1import { identify, reset, track } from "@viakite/react-native";
    2
    3identify("user_8231", { plan: "pro" }); // on sign-in
    4track("Purchase", { revenue: 499, currency: "INR", plan: "pro" });
    5reset(); // on sign-out

    The user id is kept on the device, so it lasts across app starts until reset().

  4. Read the numbers

    Screens show in Pages on the hostname app, events in Events, people in Users, and the app as ReactNative in Devices. Build funnels and retention on signed-in users to follow people across days.

What to watch

  • React Native only. There is no native Swift, Kotlin or Flutter SDK. From another app, send events through your backend with a secret key: see Backend and server events.
  • Allowed hostnames. If your project lists allowed hostnames, add app (or your host option), or the app's events are dropped.
  • Old events are dropped. Up to 1,000 events wait on the device, and one older than a day isn't stored.
  • One project or two. Use one project for the app and the site to see them together, or a project per app to keep them apart (Projects).
  • Crashes and over-the-air updates are Monitoring and Updates, which are coming soon.