clerk-cookie
released this
12 Dec 19:29
·
40 commits
to main
since this release
Minor Changes
-
Introduce improved offline support for Expo. (#4604) by @anagstef
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.It solves issues as the following:
- Faster resolution of the
isLoaded
property and theClerkLoaded
component, with only a single network fetch attempt, and if it fails, it falls back to the cached resources. - The
getToken
function ofuseAuth
hook now returns a cached token if network errors occur. - Developers can now catch and handle network errors gracefully in their custom flows, as the errors are no longer muted.
How to use it:
-
Install the
expo-secure-store
package in your project by running:npm i expo-secure-store
-
Use
import { secureStore } from "@clerk/clerk-expo/secure-store"
to import our implementation of theSecureStore
API. -
Pass the
secureStore
in the__experimental_resourceCache
property of theClerkProvider
to enable offline support.
import { ClerkProvider, ClerkLoaded } from '@clerk/clerk-expo'; import { Slot } from 'expo-router'; import { tokenCache } from '../token-cache'; import { secureStore } from '@clerk/clerk-expo/secure-store'; export default function RootLayout() { const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!; if (!publishableKey) { throw new Error('Add EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY to your .env file'); } return ( <ClerkProvider publishableKey={publishableKey} tokenCache={tokenCache} __experimental_resourceCache={secureStore} > <ClerkLoaded> <Slot /> </ClerkLoaded> </ClerkProvider> ); }
- Faster resolution of the
Patch Changes
- Updated dependencies [
e80166e08c8e230ce9ee48f2eaef3b27996b7557
,66ad299e4b6496ea4a93799de0f1ecfad920ddad
,dd3fdc7b2a96ddb90b33c6f1cefb055a60f99a9d
,e1748582d0c89462f48a482a7805871b7065fa19
,85a36a8ed615c968e9b381be97db797d96f69acc
,63b95ad5c0463f4d10db08f18f97e7c94102930d
,7f7edcaa8228c26d19e9081979100ada7e982095
,c7d7f45947c151342cfb2f7ffd67628da4cebdd7
,dd3fdc7b2a96ddb90b33c6f1cefb055a60f99a9d
]:- @clerk/[email protected]
- @clerk/[email protected]
- @clerk/[email protected]
- @clerk/[email protected]