# Expo (/docs/reference/expo)

```ts
import { … } from "@monarcode/session-kit/expo";
```

Guide: [Expo Router](/docs/setups/expo).

## Functions [#functions]

### rememberDeepLink [#rememberdeeplink]

Keeps an incoming deep link, so `SessionGate` can open it after the user signs in. Without it, `Stack.Protected` sends a signed-out user from a guarded screen to one they may see, and the link is lost.

### secureStorage [#securestorage]

Saves the session with `expo-secure-store`: in the iOS keychain, and encrypted with an Android Keystore key on Android. Pass it as `createAuth`'s `storage` in Expo apps.

## Components [#components]

### SessionGate [#sessiongate]

Wraps the root navigator in `app/_layout.tsx`. It adds what Expo Router's `Stack.Protected` lacks: a splash screen held while the session is restored, a screen for when access is unavailable, and deep links kept for after sign-in.

## Types [#types]

### RememberDeepLinkOptions [#rememberdeeplinkoptions]

Options for [`rememberDeepLink`](#rememberdeeplink), the same as `safeReturnTo`'s. Set `loginPath` when your sign-in screen isn't `/login`, so links to it are dropped rather than kept.

### RememberDeepLinkOptions

Options for rememberDeepLink, the same as `safeReturnTo`'s. Set
`loginPath` when your sign-in screen isn't `/login`, so links to it are
dropped rather than kept.

| Prop         | Type    | Description                                                                                                                                                                                                      |
| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loginPath?` | `union` | Your sign-in page's path, or several. A path to it is replaced with `"/"`, so signing in never sends the user back to sign in. Matched ignoring case, percent-encoding and trailing slashes. Default: `"/login"` |

### SecureStorageOptions [#securestorageoptions]

Options for [`secureStorage`](#securestorage). Both are for iOS: when the keychain may be read, and what happens to a session an earlier install left there.

### SecureStorageOptions

Options for secureStorage. Both are for iOS: when the keychain may
be read, and what happens to a session an earlier install left there.

| Prop                  | Type     | Description                                                                                                                                                                                                                                                                                                                                             |
| --------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `keychainAccessible?` | `number` | When iOS lets the app read the session: one of SecureStore's constants, such as `AFTER_FIRST_UNLOCK`. An app that refreshes in a background task before the device's first unlock needs `AFTER_FIRST_UNLOCK`. Passed to SecureStore unchanged. While the keychain can't be read, the session is `unavailable`, not signed out. Default: `WHEN_UNLOCKED` |
| `clearOnReinstall?`   | `union`  | Whether a reinstalled app starts signed out. iOS keeps keychain items after the app is deleted, so a session an earlier install left is removed before it's read. `false` restores it instead. Default: `true`                                                                                                                                          |

### SessionGateProps [#sessiongateprops]

Props for [`SessionGate`](#sessiongate): the root navigator, what to show while access is unavailable, and what else the splash screen waits for.

### SessionGateProps

Props for SessionGate: the root navigator, what to show while access
is unavailable, and what else the splash screen waits for.

| Prop           | Type              | Description                                                                                                                                                                                                                                                                                                                                                                                                           |
| -------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `children?`    | `ReactNode`       | The root navigator, usually a `Stack` guarded with `Stack.Protected`.                                                                                                                                                                                                                                                                                                                                                 |
| `unavailable?` | `function`        | Shown instead of the navigator while access is unavailable, such as after a failed refresh. Without it, the error is thrown to the root layout's `ErrorBoundary`. That boundary's `retry` only renders again, and a failed refresh stays failed until `auth.retry()`, so call both.                                                                                                                                   |
| `client?`      | `RetryableSource` | The client to watch. Default: the nearest `AuthProvider`'s.                                                                                                                                                                                                                                                                                                                                                           |
| `ready?`       | `union`           | Whether the rest of the app is ready for its first screen, such as fonts or remote config. Until it's `true`, and while the session is restored, the gate renders nothing and keeps the splash screen up. It only holds the splash screen the first time, even if the gate remounts. Setting it `false` later changes nothing on screen, but the deep link opened after a sign-in still waits for it. Default: `true` |

### UnavailableProps [#unavailableprops]

What the `unavailable` render prop of an adapter component, such as React Router's `SessionOutlet` or Expo's `SessionGate`, receives.

### UnavailableProps

What the `unavailable` render prop of an adapter component, such as React
Router's `SessionOutlet` or Expo's `SessionGate`, receives.

| Prop    | Type       | Description                                                                     |
| ------- | ---------- | ------------------------------------------------------------------------------- |
| `error` | `union`    | Why access is unavailable, such as a failed refresh or a locked keychain.       |
| `retry` | `function` | Tries again, as `auth.retry()` does. A repeated failure stays in `state.error`. |