Skip to content

useAuth

Hook with no arguments that returns two authentication functions used internally by React Bricks to execute the login and logout.

When using React Bricks admin components, there should be no need to call this from your code.

const { loginUser, logoutUser } = useAuth()

Function with the following signature:

const loginUser: (email: string, password: string) => Promise<any>
const { loginUser } = useAuth()
const handleLogin = (event: React.FormEvent) => {
event.preventDefault()
loginUser(email, password).then(
() => navigate(editorPath),
(error) => {
setError(error)
}
)
}

Function with the following signature:

const logoutUser: () => void
const { logoutUser } = useAuth()
return <button onClick={() => logoutUser()}>Logout</button>