react-native-rn-credential-manager
v0.1.0
Published
react native plugin for jetpack compose credential manager
Downloads
4
Readme
Credential Manager
Credential Manager is a Jetpack API that supports multiple sign-in methods, such as username and password, passkeys, and federated sign-in solutions (like Sign-in with Google) in a single API, simplifying integration for developers.
For users, Credential Manager unifies the sign-in interface across authentication methods, making it clearer and easier to sign into apps, regardless of the chosen method.
Note: This package is currently only supported for Android.
Getting Started
Add the dependency to your package.json
file:
sh
npm install react-native-rn-credential-manager
Setup Android
Add proguard rules: Create or update
android/app/proguard-rules.pro
:-if class androidx.credentials.CredentialManager -keep class androidx.credentials.playservices.** { *; }
Update
android/app/build.gradle
:android { buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } }
Usage in React Native
Import the package:
import credentialManager from 'react-native-rn-credential-manager';
Check if the platform is supported:
if (credentialManager.instance.isSupported()) { // Supported }
Initialize the Credential Manager:
await credentialManager.instance.init( true, // preferImmediatelyAvailableCredentials googleClientId // Optional for Google Sign-In );
Save credentials:
await credentialManager.instance.savePasswordBasedCredential(username, password);
Save Google credentials:
const gCredential = await credentialManager.instance.signInWithGoogle(true);
Get saved credentials:
const credential = await credentialManager.instance.getCredentials(null, { passKeyEnabled: true, passwordBasedCredentialEnabled: true, googleCredentialsEnabled: true, });
Logout:
await credentialManager.instance.logout();
Additional Setup
Error Handling
For detailed error codes and messages, see Error Handler.
Properties and Methods
For a complete list of properties and methods, see Properties and Methods.
Upcoming Features
- iOS Support
Contributing
Contributions are welcome! Please see the Contributing Guidelines for more details.
If you find this package useful, please:
- Star it on GitHub
- Tweet about it
- Mention it in your blog posts
For bug reports, feature requests, or questions, please open an issue on GitHub.