Choose your Authentication Method
Openfort React Native supports multiple authentication methods. Choose the one that fits your app.
Using Email Authentication
Use useEmailAuth
for traditional email/password authentication. Supports sign up, login, password reset, and email linking.
import { useEmailAuth } from "@openfort/react-native"
function EmailLogin() {
const { signInEmail, signUpEmail, isLoading } = useEmailAuth()
const handleSignIn = async () => {
const result = await signInEmail({
email: 'user@example.com',
password: 'password123'
})
if (result.requiresEmailVerification) {
// Prompt user to check inbox for verification code
}
}
return (
<Button
title="Sign In"
onPress={handleSignIn}
disabled={isLoading}
/>
)
}
Using Social Authentication
Use useOAuth
for social login (Google, Facebook, Twitter, etc.) and account linking.
import { OAuthProvider, useOAuth } from "@openfort/react-native"
function SocialLogin() {
const { initOAuth, isLoading } = useOAuth()
const loginWithGoogle = () => initOAuth({ provider: OAuthProvider.GOOGLE })
return (
<Button
title="Sign in with Google"
onPress={loginWithGoogle}
disabled={isLoading}
/>
)
}
Using Wallet Authentication
Use useWalletAuth
to connect external wallets (MetaMask, WalletConnect, etc.) with SIWE.
import { useWalletAuth } from "@openfort/react-native"
function WalletLogin({ walletAddress }: { walletAddress: string }) {
const { generateSiweMessage, signInWithSiwe, isLoading } = useWalletAuth()
const startLogin = async () => {
const { message } = await generateSiweMessage({
wallet: walletAddress,
from: { domain: 'example.com', uri: 'https://example.com' },
})
if (!message) return
const signature = await signMessageWithWallet(message)
await signInWithSiwe({ walletAddress, signature, messageOverride: message })
}
return (
<Button
title="Connect Wallet"
onPress={startLogin}
disabled={isLoading}
/>
)
}
Using Guest Authentication
Use useGuestAuth
for anonymous users and instant onboarding.
import { useGuestAuth } from "@openfort/react-native"
function GuestLogin() {
const { signUpGuest, isLoading } = useGuestAuth()
return (
<Button
title="Try as guest"
onPress={() => signUpGuest()}
disabled={isLoading}
/>
)
}
Using Your Own Authentication
Openfort supports integrating with external authentication providers like Firebase, Supabase, Auth0, and custom auth systems. This allows you to use your existing authentication while creating embedded wallets for users.