'use client' import { useState } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { Search, Loader2, Globe, AlertCircle, ArrowRight } from 'lucide-react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { cn } from '@/lib/utils' interface PreviewData { title: string description: string favicon: string url: string } export function LiveSerpPreview() { const [url, setUrl] = useState('') const [isLoading, setIsLoading] = useState(false) const [data, setData] = useState(null) const [error, setError] = useState('') const handleAnalyze = async (e: React.FormEvent) => { e.preventDefault() if (!url) return setIsLoading(true) setError('') setData(null) try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3002'}/api/tools/meta-preview`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url }) }) if (!response.ok) throw new Error('Failed to fetch preview') const result = await response.json() setData(result) } catch (err) { setError('Could not analyze this URL. Please check if it represents a valid, publicly accessible website.') } finally { setIsLoading(false) } } return (
{/* Background Gradients */}
Free Tool

See how Google sees you

Enter your URL to get an instant SERP preview.

{/* Input Form */}
setUrl(e.target.value)} placeholder="website.com" className="pl-9 h-12 bg-transparent border-none shadow-none focus-visible:ring-0 text-base" />
{/* Error Message */} {error && ( {error} )} {/* Result Preview */} {data && ( {/* Google Result Card */}
{data.favicon ? ( Favicon ) : ( )}
{new URL(data.url).hostname} {data.url}

{data.title}

{data.description}

{/* Upsell / CTA */}

Want to know when this changes?

)}
) }