22
33` react-supabase ` is a React Hooks library for [ Supabase] ( https://supabase.io ) .
44
5+ With ` react-supabase ` , components can request and access data declaratively without needing to handle state updates on their own.
6+
57<br />
68
79## Installation
810
9- Inside your React project directory, install:
10-
1111```
1212yarn add react-supabase @supabase/supabase-js
1313# or
@@ -33,7 +33,7 @@ const App = () => (
3333)
3434```
3535
36- Now every component and element inside and under the ` Provider ` can use the Supabase client:
36+ Now every component inside and under the ` Provider ` can use the Supabase client:
3737
3838``` js
3939import { useSelect } from ' react-supabase'
@@ -57,6 +57,82 @@ const Todos = () => {
5757
5858<br />
5959
60+ ### API
61+
62+ #### Auth
63+
64+ ``` js
65+ useAuthStateChange ((event , session ) => {
66+ console .log (` Supbase auth event: ${ event } ` , session)
67+ })
68+ ```
69+
70+ ``` js
71+ const [{ error , fetching }, resetPassword ] = useResetPassword ({
72+ options: {
73+ redirectTo: ' https://example.com/welcome' ,
74+ },
75+ })
76+
77+ const { error } = await resetPassword (' user@example.com' , {
78+ redirectTo: ' https://example.com/reset' ,
79+ })
80+ ```
81+
82+ ``` js
83+ const [{ error , fetching , user , session }, signIn ] = useSignIn ({
84+ // provider: 'github',
85+ options: {
86+ redirectTo: ' https://example.com/dashboard' ,
87+ // scopes: 'repo gist notifications',
88+ },
89+ })
90+
91+ const { error , session , user } = await signIn (
92+ {
93+ email: ' user@example.com' ,
94+ password: ' foobarbaz' , // omit for magic link
95+ // provider: 'github',
96+ },
97+ {
98+ redirectTo: ' https://example.com/dashboard' ,
99+ // scopes: 'repo gist notifications',
100+ },
101+ )
102+ ```
103+
104+ ``` js
105+ const [{ error , fetching }, signOut ] = useSignOut ()
106+
107+ const { error } = await signOut ()
108+ ```
109+
110+ ``` js
111+ const [{ error , fetching , user , session }, signUp ] = useSignUp ({
112+ options: {
113+ redirectTo: ' https://example.com/dashboard' ,
114+ },
115+ })
116+
117+ const { error , session , user } = await signUp (
118+ {
119+ email: ' user@example.com' ,
120+ password: ' foobarbaz' ,
121+ },
122+ {
123+ redirectTo: ' https://example.com/dashboard' ,
124+ },
125+ )
126+ ```
127+
128+ #### Data
129+
130+ #### Realtime
131+
132+ #### Storage
133+
134+ <br />
135+
60136## License
61137
62138The MIT License.
0 commit comments