> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clariodesk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# React Native lifecycle

> The four host events that touch the SDK, in React Native.

Four host events interact with the SDK. The concepts are shared across both
SDKs ([read the overview](/concepts/identity-lifecycle)); this page gives the
exact React Native code.

## 1. App launch (every time)

Identify **unconditionally** on launch so users who installed before you added
ClarioDesk aren't left as unlabeled devices. `identify()` is idempotent and
cheap.

```ts theme={null}
import 'react-native-get-random-values';
import { ClarioDesk } from '@clariodesk/react-native';

await ClarioDesk.init({ apiKey: 'pk_live_…' });

const user = await yourAuth.currentUser();
if (user) {
  await ClarioDesk.identify({
    externalId: user.id,
    email: user.email,
    traits: { plan: user.plan },
  });
}
```

## 2. Fresh login or signup

```ts theme={null}
await yourAuth.signIn(email, password);
await ClarioDesk.identify({ externalId: user.id, email: user.email });
```

This overwrites the label on the existing device row. The same device and key
are reused.

## 3. Logout

```ts theme={null}
await ClarioDesk.clearIdentity(); // Verified identity
await yourAuth.signOut();
```

This preserves the device key while changing the signed identity epoch. In
label-only mode, `reset()` is still available for full installation isolation.

## 4. User switch (A → B without restart)

```ts theme={null}
await ClarioDesk.clearIdentity();
await yourAuth.switchTo(userB);
await ClarioDesk.identify({ identityMode: 'host' });
```

<Warning>
  Await clear before activating user B. `reset()` deprovisions this installation;
  it is not logout or customer erase.
</Warning>

## Checking state

```ts theme={null}
ClarioDesk.isInitialized(); // boolean
ClarioDesk.isIdentified();  // boolean
```
