Skip to main content

Sign in with Apple

This guide teaches you how to add native Sign in with Apple to your Clerk apps on Apple platforms.

Important

This setup covers the native flow only. Clerk identifies the native app with its exact App ID Prefix and Bundle ID. If your app uses hosted authentication, Account Portal opens in a browser, where Sign in with Apple uses hosted Apple credentials instead. On production instances, configure those through the Apple social connection.

Note

Sign in with Apple works on both iOS Simulators and physical devices. However, physical devices provide full functionality including biometric authentication (Face ID/Touch ID), while simulators have limited support. Always test on a physical device before releasing to production.

From your Xcode project or workspace directory, run the Clerk CLI with npx and choose to enable native Sign in with Apple:

terminal
npx clerk@latest init

The CLI adds the Apple entitlement, registers your native app, and enables Native API and Apple sign-in on the linked development instance. Existing hosted Apple credentials are preserved. To add Apple sign-in after an earlier setup, run npx clerk@latest init --sign-in-with-apple.

Note

If Xcode signs your app with a Personal Team (the free team that comes with an Apple Account), the CLI skips the Sign in with Apple option, and --sign-in-with-apple fails. Choose your Apple Developer Program team in Xcode's Signing & Capabilities tab before trying again.

The CLI reuses the App ID Prefix of an existing registration for your Bundle ID. If an earlier run saved the Personal Team's ID, update the registration on Native applications to match the App ID Prefix shown for your app's identifier in the Apple Developer portal before rerunning the CLI.

The CLI reads your Bundle ID and uses the App ID Prefix from a matching Clerk registration or, otherwise, your project's signing team, which is usually the same. If it asks for a prefix, copy App ID Prefix from your app's identifier in the Apple Developer portal; it's usually your Apple Team ID.

Clerk needs a registration for every Bundle ID your apps sign in with, including when a target builds with a different Bundle ID on each platform. clerk init registers the Bundle ID of the target you choose and saves it on the Apple social connection. It stops if you rerun clerk init --sign-in-with-apple for another Bundle ID. For each additional Bundle ID, add the app on the Native applications page of the same Clerk application and development instance. Then add the Sign in with Apple capability to every target that signs in.

For a customized app, finish any remaining Swift integration with the iOS QuickstartiOS Icon, then build and test sign-in.

Add your native application

On the Native applications page in the Clerk Dashboard, enable the Native API, then add your iOS application. You will need your iOS app's App ID Prefix and Bundle ID.

To add an app for another Apple platform, such as macOS, select the iOS tab and select Add iOS app. If your apps have different Bundle IDs, add each one. If they share a Bundle ID, add it once. After you complete the remaining steps, Sign in with Apple works in each app.

Enable Apple as a social connection

  1. In the Clerk Dashboard, navigate to the SSO connections page.
  2. Select Add connection and select For all users.
  3. Select Apple from the provider list.
  4. Ensure that Enable for sign-up and sign-in is toggled on.
  5. At the top of the page, select Enable connection.

Note

Apple provides a privacy feature called Hide My Email, allowing users to sign in to your app with Apple without disclosing their actual email addresses. Instead, your instance receives an app-specific email address that forwards any emails to the user's real address. To be able to send emails properly to users with hidden addresses, you must configure an additional setting in the Apple Developer portal. See Configure Email Source for Apple Private Relay for more information.

Note

If you are using Clerk's prebuilt components, you don't need to do anything else and can stop here. The SignInWithApple button will appear in your AuthView automatically. If you are building a , continue to follow the steps below.

Build your sign-in flow

Use clerk.auth.signInWithApple() to start the native Sign in with Apple flow:

try await clerk.auth.signInWithApple()

signInWithApple() creates the request to Apple and sets its nonce, a random single-use value that Apple copies into the ID token. If you create your own ASAuthorizationAppleIDRequest and pass its ID token to signInWithIdToken(_:provider:)iOS Icon, set the request's nonce to a random value first. Without a nonce, Clerk can reject the token with an authorization_invalid error.

Configure your production instance

clerk init configures only the linked development instance. For production, add each app's exact App ID Prefix and Bundle ID registration to the production instance, enable the Native API, enable Apple as a social connection, configure the Release build with the production , and add the production associated domain to its entitlements path. A native-only Apple flow still doesn't need hosted Apple credentials.

clerk deploy and clerk deploy status check the Clerk side of this setup. For a native-only Apple flow, they count native Sign in with Apple as configured once the production instance has a registration for the Bundle ID saved on the Apple social connection, Native API is enabled, and Apple is enabled. Until then, they explain what's missing and link to the production instance's Native applications page. They don't check your other apps, so confirm that each one is registered on the production instance too. If the Apple social connection also has hosted Apple credentials, they don't check the native setup, so confirm on the production instance's Native applications page that Native API is enabled and each app is registered.

Run clerk doctor to check your Release configuration's native registration (Bundle ID and App ID Prefix), associated domain, and, when it can be read, Publishable Key against production. It also checks that Native API is enabled on the production instance. Pass --xcode-configuration <name> to check another non-Debug configuration.

Troubleshooting

I’m not receiving the user’s first and last name from Apple

Apple only provides fullName the very first time a user authorizes your app with Sign in with Apple. On subsequent sign-ins (or if the user already authorized your app in the past), Apple does not resend the name.

If you expected a name and didn’t receive one, check the following:

  • First-time authorization only: If this isn’t the user’s first authorization for this app, Apple will not return fullName. You should store the name the first time you receive it and treat it as optional after that. Deleting the user from Clerk does not reset this on Apple’s side.
  • Requested scopes: Make sure your Sign in with Apple request includes the fullName scope (and email, if you need it). If fullName wasn’t requested, Apple won’t prompt the user to share it.
  • User denied name sharing: If the user chooses not to share their name, Apple won’t provide it. Make sure your UI can collect a name as a fallback.

To test the first-time flow again, delete the user from Clerk, revoke the app's authorization using the steps for your platform below, then sign in again:

  • iOS: Go to Settings → your name → Sign in with Apple → your app or developer → Delete.
  • macOS: Go to System Settings → your name → Sign in with Apple and stop using Sign in with Apple for your app or developer.

Revoking authorization resets your app and any apps grouped with it under one primary App ID for Sign in with Apple. Revoke other apps separately.

Feedback

What did you think of this content?

Last updated on