@fortressauth/react-native-sdk
v0.1.12
Published
React Native SDK for FortressAuth with token-based authentication.
Readme
@fortressauth/react-native-sdk
React Native SDK for FortressAuth with token-based authentication.
Features
AuthProviderwithuseAuthanduseUserhooks- Token-based auth (no cookies)
- AsyncStorage-backed token storage (overrideable)
Installation
npm install @fortressauth/react-native-sdk
# or
pnpm add @fortressauth/react-native-sdk
# or
yarn add @fortressauth/react-native-sdkQuick Start
import { AuthProvider, useAuth, useUser } from '@fortressauth/react-native-sdk';
export function App() {
return (
<AuthProvider baseUrl="http://localhost:3000">
<Root />
</AuthProvider>
);
}
function Root() {
const { signIn, loading, error } = useAuth();
const { user } = useUser();
return null;
}Custom Storage
import type { AuthStorage } from '@fortressauth/react-native-sdk';
const storage: AuthStorage = {
getItem: async (key) => /* ... */,
setItem: async (key, value) => /* ... */,
removeItem: async (key) => /* ... */,
};
<AuthProvider baseUrl="http://localhost:3000" storage={storage}>
<App />
</AuthProvider>License
MIT
