Skip to main content

Sign out a user

Use the useWeb3AuthDisconnect hook to end the current authenticated session.

Import

import { useWeb3AuthDisconnect } from '@web3auth/react-native-sdk'

Usage

import { useWeb3AuthDisconnect } from '@web3auth/react-native-sdk'

function LogoutButton() {
const { disconnect, loading, error } = useWeb3AuthDisconnect()

return (
<View>
<Button
title={loading ? 'Signing out…' : 'Sign out'}
disabled={loading}
onPress={() => disconnect()}
/>
{error && <Text style={{ color: 'red' }}>{error.message}</Text>}
</View>
)
}

Calling disconnect() clears the persisted session from device storage. After it resolves, useWeb3Auth().isConnected becomes false and the provider becomes null.

On this page