Sign in with Apple
This guide will teach you how to add native Sign in with Apple to your Clerk Expo application.
Add your Native Application
Add your iOS application to the Native applications page in the Clerk Dashboard. You will need your iOS app's App ID Prefix (Team ID) and Bundle ID.
Enable Apple as a social connection
- In the Clerk Dashboard, navigate to the SSO connections page.
- Select Add connection and select For all users.
- Select Apple from the provider list.
- Ensure that Enable for sign-up and sign-in is toggled on.
The useSignInWithApple() hook requires the following packages:
expo-apple-authenticationprovides access to Apple's native Sign in with Apple functionality.expo-cryptois used for generating secure nonces during the authentication flow.
npx expo install expo-apple-authentication expo-cryptopnpm dlx expo install expo-apple-authentication expo-cryptoyarn dlx expo install expo-apple-authentication expo-cryptobun x expo install expo-apple-authentication expo-cryptoAdd expo-apple-authentication to your app config
Add the expo-apple-authentication plugin to your app.json or app.config.js.
{
"expo": {
"plugins": ["expo-apple-authentication"]
}
}export default {
expo: {
plugins: ['expo-apple-authentication'],
},
}-
The following example demonstrates how to use the useSignInWithApple() hook to manage the Apple authentication flow. Because the
useSignInWithApple()hook automatically manages the between sign-up and sign-in, you can use this component for both your sign-up and sign-in pages.components /AppleSignInButton.tsx import { useSignInWithApple } from '@clerk/expo/apple' import { useRouter } from 'expo-router' import { Alert, Platform, Pressable, StyleSheet, Text, View } from 'react-native' export function AppleSignInButton({ onSignInComplete }: { onSignInComplete?: () => void }) { const { startAppleAuthenticationFlow } = useSignInWithApple() const router = useRouter() // Only show on iOS if (Platform.OS !== 'ios') return null const handleAppleSignIn = async () => { try { const { createdSessionId, setActive } = await startAppleAuthenticationFlow() if (createdSessionId && setActive) { await setActive({ session: createdSessionId }) if (onSignInComplete) { onSignInComplete() } else { router.replace('/') } } } catch (err: any) { if (err.code === 'ERR_REQUEST_CANCELED') return Alert.alert('Error', err.message || 'An error occurred during Apple sign-in') console.error('Sign in with Apple error:', JSON.stringify(err, null, 2)) } } return ( <View style={styles.container}> <Pressable style={({ pressed }) => [styles.button, pressed && styles.buttonPressed]} onPress={handleAppleSignIn} > <Text style={styles.buttonText}>Continue with Apple</Text> </Pressable> </View> ) } const styles = StyleSheet.create({ container: { width: '100%', marginVertical: 8, }, button: { backgroundColor: '#000', paddingVertical: 14, paddingHorizontal: 24, borderRadius: 8, alignItems: 'center', }, buttonPressed: { opacity: 0.7, }, buttonText: { color: '#fff', fontSize: 16, fontWeight: '600', }, }) -
Then, add the
<AppleSignInButton />component to your sign-in or sign-up page.
Create a native build
Create a native build with EAS Build or a local prebuild, since Apple Authentication is not supported in Expo Go.
# Using EAS Build
eas build --platform ios
# Or using local prebuild
npx expo prebuild && npx expo run:ios --deviceFeedback
Last updated on