You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're introducing an improved offline support for the `@clerk/clerk-expo` package to enhance reliability and user experience. This new improvement allows apps to bootstrap without an internet connection by using cached Clerk resources, ensuring quick initialization.
8
+
9
+
It solves issues as the following:
10
+
11
+
- Faster resolution of the `isLoaded` property and the `ClerkLoaded` component, with only a single network fetch attempt, and if it fails, it falls back to the cached resources.
12
+
- The `getToken` function of `useAuth` hook now returns a cached token if network errors occur.
13
+
- Developers can now catch and handle network errors gracefully in their custom flows, as the errors are no longer muted.
14
+
15
+
How to use it:
16
+
17
+
1. Install the `expo-secure-store` package in your project by running:
18
+
19
+
```bash
20
+
npm i expo-secure-store
21
+
```
22
+
23
+
2. Use `import { secureStore } from "@clerk/clerk-expo/secure-store"` to import our implementation of the `SecureStore` API.
24
+
3. Pass the `secureStore`in the `__experimental_resourceCache` property of the `ClerkProvider` to enable offline support.
25
+
26
+
```tsx
27
+
import { ClerkProvider, ClerkLoaded } from '@clerk/clerk-expo'
28
+
import { Slot } from 'expo-router'
29
+
import { tokenCache } from '../token-cache'
30
+
import { secureStore } from '@clerk/clerk-expo/secure-store'
This change also introduces two new internal methods on the Clerk resource, to be used by the expo package.
10
+
11
+
-`__internal_getCachedResources()`: (Optional) This function is used to load cached Client and Environment resources if Clerk fails to load them from the Frontend API.
12
+
-`__internal_reloadInitialResources()`: This funtion is used to reload the initial resources (Environment/Client) from the Frontend API.
0 commit comments