A function (data) => Promise<null | string>. Call with { email, password }. Returns null on success, or the error message on failure (e.g. "Invalid password").
import { useLogin } from "naystack/auth/client";
function LoginForm() {
const login = useLogin();
const handleSubmit = async (data: { email: string; password: string }) => {
const error = await login(data);
if (error) {
form.setError("password", { message: error });
} else {
router.replace("/dashboard");
}
};
}
Returns a login function that PUTs to the auth endpoint with credentials. On success, the response's
accessTokenis stored and the token context updates automatically.