@intastellar/signin-sdk-react-native
v1.1.1
Published
Official Intastellar authentication SDK for React Native applications
Downloads
9
Maintainers
Readme
@intastellar/signin-sdk-react-native
Official Intastellar authentication SDK for React Native applications with support for both Expo and bare React Native projects.
Installation
npm install @intastellar/signin-sdk-react-nativeDependencies for Bare React Native
If you're using a bare React Native project, install these dependencies:
npm install @react-native-async-storage/async-storage react-native-inappbrowser-rebornDependencies for Expo
If you're using Expo (managed workflow), install these dependencies:
npx expo install @react-native-async-storage/async-storage expo-web-browser expo-constantsiOS Setup (Bare React Native only)
For bare React Native projects, run:
cd ios && pod installAndroid Setup
No additional setup needed for Android in either Expo or bare React Native projects.
Platform Support
This SDK automatically detects whether you're using Expo or bare React Native and uses the appropriate browser implementation:
- Expo projects: Uses
expo-web-browserfor in-app authentication - Bare React Native: Uses
react-native-inappbrowser-rebornfor in-app authentication - Fallback: Falls back to the device's default browser if in-app browsing is unavailable
Usage
Basic Usage
import { IntastellarButton } from "@intastellar/signin-sdk-react-native";
function App() {
const handleLogin = (account) => {
console.log("User logged in:", account);
};
return (
<IntastellarButton
clientId="your-client-id"
loginUri="myapp://auth"
loginCallback={handleLogin}
/>
);
}Using the Hook
import { useIntastellarRN } from "@intastellar/signin-sdk-react-native";
function MyComponent() {
const { users, isLoading, signin, logout, isSignedIn } = useIntastellarRN({
clientId: "your-client-id",
loginUri: "myapp://auth",
});
return (
<View>
{isSignedIn ? (
<TouchableOpacity onPress={logout}>
<Text>Sign Out</Text>
</TouchableOpacity>
) : (
<TouchableOpacity onPress={() => signin()}>
<Text>Sign In</Text>
</TouchableOpacity>
)}
</View>
);
}Configuration
| Property | Type | Required | Description |
| --------------- | -------- | -------- | ----------------------------------------- |
| clientId | string | Yes | Your Intastellar application client ID |
| loginUri | string | Yes | Deep link URI for authentication redirect |
| scopes | string | No | OAuth scopes (default: "profile,email") |
| theme | object | No | Theme configuration |
| loginCallback | function | No | Callback when login succeeds |
| errorCallback | function | No | Callback when login fails |
Deep Link Setup
iOS (Info.plist)
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>myapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
</array>Android (AndroidManifest.xml)
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent-filter>
</activity>License
MIT © Intastellar Solutions International
