Apple ID sign-in
Users authenticate through Apple ID in a Next.js application.
Auth.js · Const
Auth.js provides a built-in Apple OAuth provider. Add Apple to the providers array and configure AUTH_APPLE_ID plus AUTH_APPLE_SECRET.
Apple is a built-in OAuth provider for Auth.js. Add the provider to the providers array, configure the required environment variables, and use the provider’s callback endpoint for the Apple developer configuration.
Appleimport NextAuth from "next-auth"
import Apple from "next-auth/providers/apple"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Apple],
})Register the built-in Apple provider in a NextAuth configuration; supply AUTH_APPLE_ID and AUTH_APPLE_SECRET in the environment.
Users authenticate through Apple ID in a Next.js application.
An application needs a built-in OAuth integration without implementing Apple’s protocol itself.
A project supports multiple Auth.js providers and wants Apple alongside them.
Import Apple from the framework-specific provider package and include Apple in the Auth.js providers array. The standard environment variables are AUTH_APPLE_ID and AUTH_APPLE_SECRET.
Follow-up: What callback URL should be registered? Use the application’s HTTPS callback endpoint, such as https://example.com/api/auth/callback/apple for Next.js.
Apple uses the callback path ending in /callback/apple. In a Next.js application, the documented form is https://example.com/api/auth/callback/apple.
Follow-up: What deployment restriction applies? Apple does not support localhost or HTTP callback URLs, so the registered URL must be a live HTTPS URL.
The client secret is not an ordinary static password: Apple requires it to be a JWT. The documented npx auth add apple command can help generate the required credentials and write the environment variables.
Follow-up: Why should the initial profile be stored? Apple supplies the user’s name and email only on the first consent, so later sign-ins may omit them.
OAuthUserConfigAppleProfileOAuthConfigcustomizing a built-in OAuth provider