import { AutoConnect } from '@coinbase/onchainkit/minikit';
import { useAccount } from 'wagmi';
import { useEffect, useState } from 'react';
function ConnectionHandler() {
const { isConnected, isConnecting } = useAccount();
const [connectionTimeout, setConnectionTimeout] = useState(false);
useEffect(() => {
if (isConnecting) {
// Set a timeout to show help text if connection takes too long
const timer = setTimeout(() => {
setConnectionTimeout(true);
}, 5000);
return () => clearTimeout(timer);
} else {
setConnectionTimeout(false);
}
}, [isConnecting]);
if (connectionTimeout) {
return (
<div className="p-4 bg-yellow-50 border border-yellow-200 rounded-lg">
<h3 className="font-semibold text-yellow-800">Connection taking longer than expected</h3>
<p className="text-yellow-700 text-sm mt-1">
Make sure you're using a compatible Farcaster client.
</p>
</div>
);
}
return null;
}
export default function MiniApp() {
return (
<AutoConnect>
<div className="p-4">
<h1>Robust Mini App</h1>
<ConnectionHandler />
{/* Rest of your app */}
</div>
</AutoConnect>
);
}