File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ $ npm i @cobuildlab/react-native-auth0
1919```
2020## Usage
2121
22+ #### Auth0 Client Setup:
23+
2224Create a new client instance using Auth0Native:
2325
2426``` tsx
@@ -66,4 +68,67 @@ export const App = () => (
6668 <App />
6769 </AuthProvider >
6870);
69- ```
71+ ```
72+
73+ #### Hook usage
74+
75+ Login View
76+
77+ ``` tsx
78+ import { View , Button } from ' react-native;
79+ import { useAuth } from ' @cobuildlab/react-native-auth0' ;
80+
81+ export const LoginView = () => {
82+ const { authorize } = useAuth ();
83+
84+ return (
85+ <View >
86+ <Button onPress = { authorize } title = " Sign in" >
87+ </View >
88+ )
89+ }
90+
91+ ```
92+
93+ Logout View
94+
95+ ```tsx
96+ import { View , Button } from 'react-native;
97+ import { useAuth } from '@cobuildlab/react-native-auth0';
98+
99+ export const LogOutView = () => {
100+ const { clearSession } = useAuth ();
101+
102+ return (
103+ <View >
104+ <Button onPress = { clearSession } title = " Sign in" >
105+ </View >
106+ )
107+ }
108+ ```
109+
110+ App Component
111+
112+ ```tsx
113+ import { useAuth } from '@cobuildlab/react-native-auth0';
114+ import { LoginView } from './LoginView';
115+ import { LogOutView } from './LogOutView';
116+ import { MainView , Loading } from './others'
117+
118+
119+ export function App() {
120+ const { isLoading , isAuthenticated , clearSession } = useAuth ();
121+
122+ if (isLoading ){
123+ return <Loading />
124+ }
125+
126+ if (! isAuthenticated ){
127+ return < LoginView />
128+ }
129+
130+ return <MainView />
131+ }
132+
133+ ```
134+
You can’t perform that action at this time.
0 commit comments