@twelvebit/react-native
v0.1.0
Published
twelvebit analytics for React Native and Expo: screen views, goals, identify, offline queue.
Maintainers
Readme
@twelvebit/react-native
twelvebit analytics for React Native and Expo: screen views, goals, identify, and an offline queue that retries with backoff. Use the same site id as your website to see web and app traffic in one dashboard, and link one person across both with identify.
Set up with your coding agent
Paste this prompt into Claude Code, Codex or Cursor in your app:
Add twelvebit analytics with the @twelvebit/react-native package.
Read https://twelvebit.app/docs/sdks.md first (the React Native section) and follow it.
1. Install it: npm i @twelvebit/react-native
and: npx expo install @react-native-async-storage/async-storage @react-native-community/netinfo
2. Wrap the app in <TwelvebitProvider config={{ siteId: "tb_…", appName: "<my app>" }}>.
3. Send a screen view for each screen (React Navigation: onStateChange on the NavigationContainer).
4. Track 3 to 8 important actions with track("snake_case_name"), call identify() with the same user id
as on the website after sign-in, and reset() at logout.
Then tell me which screens and events you added.Install
npm i @twelvebit/react-native
# Recommended (optional): persistence and network detection
npx expo install @react-native-async-storage/async-storage @react-native-community/netinfoUse
import { TwelvebitProvider, useTwelvebit, useTwelvebitScreen } from "@twelvebit/react-native";
<TwelvebitProvider config={{ siteId: "tb_YOUR_SITE_ID", appName: "myapp" }}>
<App />
</TwelvebitProvider>;
function Home() {
useTwelvebitScreen("Home"); // a page view for app://myapp/Home
const tb = useTwelvebit();
return <Button title="Buy" onPress={() => tb.track("purchase_click")} />;
}Without React: createTwelvebit(config) from @twelvebit/react-native (or @twelvebit/react-native/core, which does not import React).
Peer dependencies
| Package | Needed |
|---|---|
| react 17 or later | Yes, for the provider and hooks |
| react-native 0.70 or later | Optional (the core client also runs in Node) |
| @react-native-async-storage/async-storage | Optional: keeps the visitor id and the queue across app starts |
| @react-native-community/netinfo | Optional: sends when the network comes back |
Options, API and details: https://twelvebit.app/docs/sdks
