Supabase Integration Introduction
Konten ini belum tersedia dalam bahasa Anda.
Overview
Section titled âOverviewâThis tutorial will guide you through setting up Supabase Authentication with the Capacitor Social Login plugin. This integration allows you to use native social login providers (Google, Apple, Facebook, Twitter) on mobile platforms while leveraging Supabase Auth for backend authentication and PostgreSQL for data storage.
What Youâll Learn
Section titled âWhat Youâll Learnâ- How to configure Supabase Authentication
- How to integrate Capacitor Social Login plugin with Supabase Auth
- Platform-specific setup for Android, iOS, and Web
- How to handle nonces securely for Supabase
What Youâll Need
Section titled âWhat Youâll NeedâBefore you begin, make sure you have:
-
A Supabase Project
- Create a project at Supabase Dashboard
- Enable Google OAuth provider
- Get your Supabase project URL and anon key
-
Supabase JS SDK
- Install Supabase in your project:
Terminal window npm install @supabase/supabase-js
- Install Supabase in your project:
-
A Capacitor Project
- An existing Capacitor application
- Capacitor Social Login plugin installed:
Terminal window npm install @capgo/capacitor-social-loginnpx cap sync
-
Platform-Specific Google Setup
- Complete the Google Sign-In setup for your target platforms:
Example Application
Section titled âExample ApplicationâA complete working example is available in the repository:
Code Repository: You can find the code repository here
The example app demonstrates:
- Email/password authentication with Supabase
- Google Sign-In integration (Android, iOS, and Web)
- A simple key-value store using Supabase PostgreSQL tables
- User-specific data storage with Row Level Security (RLS)
Key Implementation Details
Section titled âKey Implementation DetailsâNonce Handling
Section titled âNonce HandlingâSupabase requires special nonce handling for security. The implementation follows the React Native Google Sign In documentation:
- Generate a
rawNonce(URL-safe random string) - Hash it with SHA-256 to get
nonceDigest - Pass
nonceDigestto Google Sign-In - Pass
rawNonceto Supabase (Supabase hashes it internally for comparison)
JWT Validation
Section titled âJWT ValidationâThe example implementation includes JWT validation to ensure:
- The token audience matches your configured Google Client IDs
- The nonce matches the expected digest
- Automatic retry on validation failure (especially important for iOS)
Platform-Specific Considerations
Section titled âPlatform-Specific Considerationsâ- iOS: Token caching can cause nonce issues - the implementation handles this automatically
- Web: Must call
isLoggedIn()on mount to handle OAuth redirects - Android: Standard implementation with SHA-1 fingerprint configuration
Next Steps
Section titled âNext StepsâContinue with the setup guides:
- Supabase Google Login - General Setup - Overview and prerequisites
- Android Setup - Android-specific configuration
- iOS Setup - iOS-specific configuration
- Web Setup - Web-specific configuration