// React Native - With Auth0
import { useAuth0 } from 'react-native-auth0';
import { useAuthenticateWithJWT } from '@coinbase/cdp-hooks';
import { Button, Text, View } from 'react-native';
function AuthScreen() {
const { authorize } = useAuth0();
const { authenticateWithJWT } = useAuthenticateWithJWT();
const [error, setError] = useState(null);
const handleLogin = async () => {
try {
// Step 1: Trigger Auth0 login (opens browser)
await authorize();
// Step 2: Authenticate with CDP
const { user, isNewUser } = await authenticateWithJWT();
console.log('Authenticated user:', user);
if (isNewUser) {
console.log('New user created with wallet!');
}
} catch (err) {
setError(err.message);
}
};
return (
<View>
<Button title="Sign In with Auth0" onPress={handleLogin} />
{error && <Text>Error: {error}</Text>}
</View>
);
}