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.

Embed
Preview of the card
<a href="https://lucidace.com/help/install-expo"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/0654acd0-a5b3-4255-bcfa-bf8221b4f7cd/social-card.svg?v=3e7ae33eec8b" alt="Install Lucida on Expo" width="600" height="315"></a>

@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-system

Or 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 ($app_installed source)

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.

Updated