Prerequisites
-
Active Apple Developer account
-
Lovable project using Lovable Cloud as backend
-
(Optional) Despia blueprint for native mobile app compatibility
Implement Frontend Setup
Start by asking Lovable to implement Apple JS (Apple's JavaScript library for native Login with Apple):
implement Apple JS inside of my app and start with the front end setup.
Lovable will create the necessary frontend components and integrate Apple's authentication library.
Register Your App ID
-
Go to Apple Developer Console
-
Navigate to Certificates, Identifiers & Profiles
-
Select Identifiers
-
Create or select your existing App ID
-
Add the Sign in with Apple capability
-
Save your configuration
Note: If using Despia, your Bundle ID is automatically generated. You can find it in your Despia project settings.
Create Service ID
-
In Apple Developer Console, create a new Service ID
-
Use the format:
[your-bundle-id].appleauth -
Enable Sign in with Apple
-
Click Configure
Configure Callback URLs
Ask Lovable for your callback URL structure:
what are my callback URLs/URL so I can register it with Apple
Then specify your preferred callback path:
make the Apple auth callback URL for OAuth /callback/Apple
In Apple Developer Console:
-
Add your Web Domain (your Lovable app URL without path)
-
Add your Return URL (the full callback URL Lovable provided)
-
Click Done and Save
Provide Service ID to Lovable
Copy your Service ID from Apple Developer Console and provide it to Lovable:
this is our service ID for Apple Auth:
[paste-your-service-id-here]
Set Up Backend Authentication
Since Lovable Cloud doesn't natively support Login with Apple, you'll need custom edge functions:
now set up the back end so when we go to /callback/apple it gets all the parameters and starts the back end auth token process and logs the user in.
Then specify the custom implementation:
Lovable Cloud does not support Apple login yet. Please implement it custom via edge functions that will do the whole job.
Use the "DESPIA README" references for that
Configure Apple Private Key
-
In Apple Developer Console, go to Keys
-
Create a new key with Sign in with Apple enabled
-
Configure it with your App ID (Bundle ID)
-
Download the private key (
.p8file) - you can only download this once! -
Copy the key ID shown in the console
Provide the private key to Lovable when prompted, followed by the key ID:
what about the key id
Then paste your key ID when requested.
Testing Your Implementation
Test on web first:
-
Publish your Lovable project
-
Open in Safari (for best Apple integration)
-
Click "Login with Apple"
-
Complete the authentication flow
The authentication should redirect you to Apple, then back to your app with a successful login.
Mobile App Considerations
When using Despia to convert your Lovable app to a native mobile application:
-
Apple JS automatically uses native iOS dialogs on Apple devices
-
The same implementation works seamlessly on both web and mobile
-
Android devices will see the web-based Apple authentication flow
Security Best Practices
After implementing Login with Apple, address any security warnings:
-
Review Lovable Cloud's security panel
-
Fix row-level security policies as suggested
-
Ensure user data is properly protected
Troubleshooting
Authentication redirects but doesn't log in
Ensure your edge function properly redirects to Supabase's verify endpoint:
it works but the auth fails at the last step with this error:
[paste-error-here]
please check the logs to see what's going on
Old edge functions causing conflicts
If you have multiple Apple auth edge functions, specify which to use:
make sure to only use the authentication callback function for Apple auth that we just created. The other Apple auth functions are old and can be deleted.
Why Custom Implementation?
Lovable Cloud (built on Supabase) doesn't yet expose Login with Apple in its UI. Custom edge functions provide:
-
Full control over the authentication flow
-
Better handling of Apple's privacy features (email masking)
-
Flexibility for user account linking logic
-
Support for changing email addresses
Additional Resources
For additional support or questions, please contact our support team at support@despia.com