Skip to main content

Quick start

Sign in​

import { AppleSignIn } from 'nitro-apple-signin'

if (AppleSignIn.isSupported()) {
const credential = await AppleSignIn.signIn({ scopes: ['fullName', 'email'], nonce: rawNonce })
if (credential !== undefined) {
// Email and name arrive only on the first sign-in: send them with the token.
await sendToBackend(
credential.identityToken,
credential.authorizationCode,
credential.fullName,
credential.email,
)
saveUserId(credential.user)
}
}
  • isSupported() is synchronous: true on iOS, false on Android. Use it to decide whether to show the button.
  • signIn resolves undefined when the user closes the sheet. That is not an error.
  • rawNonce is a random, single-use string you generate. See Backend verification.
  • sendToBackend and saveUserId are your code.

Check the credential at launch​

Users can stop using their Apple ID with your app from Settings. Check the stored user ID on launch:

const state = await AppleSignIn.getCredentialState(storedUserId)
if (state === 'revoked' || state === 'notFound') signOut()

Handle errors​

import { AppleSignIn, getAppleSignInErrorCode } from 'nitro-apple-signin'

try {
await AppleSignIn.signIn()
} catch (error) {
const code = getAppleSignInErrorCode(error) // 'IN_PROGRESS', 'SIGN_IN_FAILED', ...
}

Where to go next: