skills/clerk-expo-patterns/SKILL.md
Expo / React Native patterns with Clerk — SecureStore token cache, OAuth deep linking, useAuth in native, Expo Router protected routes, push notifications with user context. Triggers on: expo clerk, clerk react native, SecureStore token cache, expo router auth, OAuth deep link clerk, mobile auth clerk.
npx skillsauth add awfixers-stuff/opencode-config clerk-expo-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
SDK: @clerk/expo v3+. Requires Expo 53+, React Native 0.73+.
| Task | Reference | |------|-----------| | Persist tokens with SecureStore | references/token-storage.md | | OAuth (Google, Apple, GitHub) | references/oauth-deep-linking.md | | Protected screens with Expo Router | references/protected-routes.md | | Push notifications with user data | references/push-notifications.md |
Clerk stores the session token in memory by default. In native apps:
tokenCache — prop on <ClerkProvider> that provides custom storageuseAuth — same API as web, works in any componentuseSSO + deep link scheme configured in app.jsonimport { ClerkProvider } from '@clerk/expo'
import { tokenCache } from '@clerk/expo/token-cache'
import { Stack } from 'expo-router'
const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!
export default function RootLayout() {
return (
<ClerkProvider publishableKey={publishableKey} tokenCache={tokenCache}>
<Stack />
</ClerkProvider>
)
}
CRITICAL: Use
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY— notNEXT_PUBLIC_. Env vars insidenode_modulesare not inlined in production builds. Always passpublishableKeyexplicitly.
import { tokenCache } from '@clerk/expo/token-cache'
This uses expo-secure-store with keychainAccessible: AFTER_FIRST_UNLOCK. Install the peer dep:
npx expo install expo-secure-store
import { useAuth, useUser, useSignIn, useSignUp, useClerk } from '@clerk/expo'
export function ProfileScreen() {
const { isSignedIn, userId, signOut } = useAuth()
const { user } = useUser()
if (!isSignedIn) return <Redirect href="/sign-in" />
return (
<View>
<Text>{user?.fullName}</Text>
<Button title="Sign Out" onPress={() => signOut()} />
</View>
)
}
import { useSSO } from '@clerk/expo'
import * as WebBrowser from 'expo-web-browser'
WebBrowser.maybeCompleteAuthSession()
export function GoogleSignIn() {
const { startSSOFlow } = useSSO()
const handlePress = async () => {
try {
const { createdSessionId, setActive } = await startSSOFlow({
strategy: 'oauth_google',
redirectUrl: 'myapp://oauth-callback',
})
if (createdSessionId) await setActive!({ session: createdSessionId })
} catch (err) {
console.error(err)
}
}
return <Button title="Continue with Google" onPress={handlePress} />
}
import { useOrganization, useOrganizationList } from '@clerk/expo'
export function OrgSwitcher() {
const { organization } = useOrganization()
const { setActive, userMemberships } = useOrganizationList()
return (
<View>
<Text>Current: {organization?.name ?? 'Personal'}</Text>
{userMemberships.data?.map(mem => (
<Button
key={mem.organization.id}
title={mem.organization.name}
onPress={() => setActive({ organization: mem.organization.id })}
/>
))}
</View>
)
}
| Symptom | Cause | Fix |
|---------|-------|-----|
| publishableKey undefined in prod | Using env var without EXPO_PUBLIC_ | Rename to EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY |
| Token lost on app restart | No tokenCache | Pass tokenCache from @clerk/expo/token-cache |
| OAuth redirect not working | Missing scheme in app.json | Add "scheme": "myapp" to app.json |
| WebBrowser.maybeCompleteAuthSession | Not called | Call it at the top level of the OAuth callback screen |
| useSSO not found | Old @clerk/expo version | useSSO replaced useOAuth in v3+ |
| What | Import From |
|------|-------------|
| ClerkProvider | @clerk/expo |
| tokenCache | @clerk/expo/token-cache |
| useAuth, useUser, useSignIn | @clerk/expo |
| useSSO | @clerk/expo |
| useOrganization, useOrganizationList | @clerk/expo |
clerk-setup - Initial Clerk installclerk-custom-ui - Custom flows & appearanceclerk-orgs - B2B organizationsExpo SDK
development
Use when starting dev servers, watchers, tilt, or any process expected to outlive the conversation. Provides zmx session management patterns for long-lived processes.
development
Zig testing skill for writing and running tests. Use when using zig build test, writing comptime tests, using test filters, working with test allocators to detect leaks, or using Zig's built-in fuzz testing (0.14+). Activates on queries about Zig tests, zig test, zig build test, comptime testing, test allocators, Zig fuzz testing, or detecting memory leaks in Zig tests.
development
Zig debugging skill. Use when debugging Zig programs with GDB or LLDB, interpreting Zig runtime panics, using std.debug.print for tracing, configuring debug builds, or debugging Zig programs in VS Code. Activates on queries about debugging Zig, Zig panics, zig gdb, zig lldb, std.debug.print, Zig stack traces, or Zig error return traces.
tools
Zig cross-compilation skill. Use when cross-compiling Zig programs to different targets, using Zig's built-in cross-compilation for embedded, WASM, Windows, ARM, or using zig cc to cross-compile C code without a system cross-toolchain. Activates on queries about Zig cross-compilation, zig target triples, zig cc cross-compile, Zig embedded targets, or Zig WASM.