import { useState, useEffect } from 'react'; export default function Hero() { const [greeting, setGreeting] = useState('Hi'); const [apiMessage, setApiMessage] = useState(''); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/hello') .then(res => res.json()) .then(data => { setApiMessage(data.message); setLoading(false); }) .catch(() => { setApiMessage('Unable to fetch greeting'); setLoading(false); }); }, []); return (

{greeting}

Welcome to your new Next.js application

{loading ? (

Loading API greeting...

) : (

{apiMessage}

)}

Fast

Built with Next.js for optimal performance

Reliable

Type-safe and production ready

Scalable

Component-based architecture

); }