useVerifyFarcaster hook handles Farcaster authentication. It provides a Connect URI that you display as a QR code or deep link so the user can approve login in their Farcaster client.
Hook for verifying Farcaster authentication
useVerifyFarcaster hook handles Farcaster authentication. It provides a Connect URI that you display as a QR code or deep link so the user can approve login in their Farcaster client.
import { useVerifyFarcaster } from "@getpara/react-native-wallet";
import { useVerifyFarcaster } from "@getpara/react-native-wallet";
import { useState } from "react";
import { View, Text, Linking } from "react-native";
function FarcasterLogin() {
const [connectUri, setConnectUri] = useState<string | null>(null);
const { verifyFarcasterAsync, isPending } = useVerifyFarcaster();
const handleLogin = async () => {
try {
await verifyFarcasterAsync({
onConnectUri: (uri) => {
setConnectUri(uri);
// Optionally open in Warpcast
Linking.openURL(`https://warpcast.com/~/sign-in?uri=${encodeURIComponent(uri)}`);
},
});
} catch (err) {
console.error(err);
}
};
return (
<View>
{connectUri && <Text selectable>{connectUri}</Text>}
<Button title={isPending ? "Waiting..." : "Sign in with Farcaster"} onPress={handleLogin} disabled={isPending} />
</View>
);
}