Install Lucida on Expo
Add Lucida to an Expo app with @lucida-analytics/expo: works in Expo Go, session replay in development and EAS builds, Expo Router screens.
@lucida-analytics/expo is the React Native SDK with the Expo wiring done: storage, app state, the app version from app.json, platform and OS version, and the native module when the app has one. It declares expo >=50 and react-native >=0.73. The React Native SDK under it is built natively in CI on Expo SDK 52 and on the latest Expo release.
1. Install
npx expo install @lucida-analytics/expo @lucida-analytics/react-native expo-constants expo-application expo-file-systemOr let the CLI do it: lucida init --framework expo --host https://capture.lucidace.com writes EXPO_PUBLIC_LUCIDA_KEY to .env, creates lucida.ts and imports it from app/_layout.tsx (or App.tsx, index.ts). Running it twice changes nothing.
2. Add the provider
In app/_layout.tsx (Expo Router) or App.tsx:
import { Stack } from "expo-router";
import { LucidaProvider } from "@lucida-analytics/expo";
export default function RootLayout() {
return (
<LucidaProvider apiKey="lc_pk_YOUR_PUBLIC_KEY">
<Stack />
</LucidaProvider>
);
}Use the public key (lc_pk_...) from Settings > Project > Keys. Hooks (useCapture, useFeatureFlag, useLucida) and FeatureGate come from the same package.
3. Screens (Expo Router)
import { useLucida } from "@lucida-analytics/expo";
import { useExpoRouterScreens } from "@lucida-analytics/expo/router";
function Screens() { useExpoRouterScreens(useLucida()); return null; }Render <Screens /> inside the provider. Each route sends one $screen named by its template (/profile/[id]), never the real id.
4. Session replay
Replay needs native code, so it doesn't run in Expo Go. Add the config plugin to app.json, then build with npx expo run:ios, npx expo run:android or EAS Build:
{ "expo": { "plugins": ["@lucida-analytics/expo"] } }Then turn it on: <LucidaProvider apiKey="..." options={{ replay: { enabled: true } }}>. Replay also needs the replay consent category. Masking options are in the replay config reference.
Expo Go | Development or release build | |
|---|---|---|
Events, identify, flags, guides | Yes | Yes |
Session replay | No (one warning if enabled) | Yes |
Install attribution ( | No | Yes |
5. Check the first event
Open the app, then look in Activity: an $app_opened event arrives with $app_version set to your app.json version.
Every option of the React Native SDK is accepted and wins over the Expo default. Bare React Native apps (no Expo) use @lucida-analytics/react-native directly; see Install an SDK.