@@ -25,6 +25,8 @@ List of Auth hooks:
2525- [ useUpdateProfile] ( #useupdateprofile )
2626- [ useSendPasswordResetEmail] ( #usesendpasswordresetemail )
2727- [ useSendEmailVerification] ( #usesendemailverification )
28+ - [ useSignOut] ( #usesignout )
29+ - [ useDeleteUser] ( #usedeleteuser )
2830
2931### useAuthState
3032
@@ -744,3 +746,105 @@ const SendEmailVerification = () => {
744746 );
745747};
746748```
749+
750+ ### useSignOut
751+
752+ ``` js
753+ const [signOut , loading , error ] = useSignOut (auth);
754+ ```
755+
756+ Sign out current user. Wraps the underlying ` auth.signOut ` method and provides additional ` loading ` and ` error ` information.
757+
758+ The ` useSignOut ` hook takes the following parameters:
759+
760+ - ` auth ` : ` Auth ` instance for the app you would like to monitor
761+
762+ Returns:
763+
764+ - ` signOut() ` : A ` () => Promise<void> ` function you can call to sign out current user
765+ - ` loading ` : A ` boolean ` to indicate whether operation is loading
766+ - ` error ` : Any ` Error ` returned by Firebase when trying to sign out user, or ` undefined ` if there is no error
767+
768+ #### Full Example
769+
770+ ``` jsx
771+ import { useSignOut } from ' react-firebase-hooks/auth' ;
772+
773+ const SignOut = () => {
774+ const [signOut , loading , error ] = useSignOut (auth);
775+
776+ if (error) {
777+ return (
778+ < div>
779+ < p> Error : {error .message }< / p>
780+ < / div>
781+ );
782+ }
783+ if (loading) {
784+ return < p> Loading... < / p> ;
785+ }
786+ return (
787+ < div className= " App" >
788+ < button
789+ onClick= {async () => {
790+ await signOut ();
791+ alert (' You are sign out' );
792+ }}
793+ >
794+ Sign out
795+ < / button>
796+ < / div>
797+ );
798+ };
799+ ```
800+
801+ ### useDeleteUser
802+
803+ ``` js
804+ const [deleteUser , loading , error ] = useDeleteUser (auth);
805+ ```
806+
807+ Delete current user. Wraps the underlying ` auth.currrentUser.signOut ` method and provides additional ` loading ` and ` error ` information.
808+
809+ The ` useDeleteUser ` hook takes the following parameters:
810+
811+ - ` auth ` : ` Auth ` instance for the app you would like to monitor
812+
813+ Returns:
814+
815+ - ` deleteUser() ` : A ` () => Promise<void> ` function you can call to sign out current user
816+ - ` loading ` : A ` boolean ` to indicate whether operation is loading
817+ - ` error ` : Any ` Error ` returned by Firebase when trying to delete user, or ` undefined ` if there is no error
818+
819+ #### Full Example
820+
821+ ``` jsx
822+ import { useDeleteUser } from ' react-firebase-hooks/auth' ;
823+
824+ const DeleteUser = () => {
825+ const [deleteUser , loading , error ] = useDeleteUser (auth);
826+
827+ if (error) {
828+ return (
829+ < div>
830+ < p> Error : {error .message }< / p>
831+ < / div>
832+ );
833+ }
834+ if (loading) {
835+ return < p> Loading... < / p> ;
836+ }
837+ return (
838+ < div className= " App" >
839+ < button
840+ onClick= {async () => {
841+ await deleteUser ();
842+ alert (' You have been deleted' );
843+ }}
844+ >
845+ Delete current user
846+ < / button>
847+ < / div>
848+ );
849+ };
850+ ```
0 commit comments