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