Skip to main content

Auth Context

Thanks to React's context mechanism we can access auth data in the whole application. You can find AuthContext.ts inside src/store/ folder.

Context is provided inside App.ts file for the whole app thanks to wrapping MainStack.

Auth data is stored in encrypted storage. It is read on app start via useEffect to fill up context state.

Reading data from AuthContext

In any component, you can access AuthContext. Thanks to TypeScript autocomplete you'll see what methods and fields you can use.

const authContext = useContext(AuthContext)
const isLoggedIn = !!authContext.state?.token

Writing data to AuthContext

To change values inside the state you need to call one of the available methods signIn or signOut.

Both methods are async as they are accessing data on device drive. Tokens are stored inside an encrypted container (see: react-native-keychain) on devices disk.


This method saves tokens & additional data to secure storage.


This method removes tokens & additional data from secure storage.