Complete the code to create a simple Next.js page component.
export default function Home() {
return <main>[1]</main>;
}The main content of a Next.js page is returned as JSX inside the component function.
Complete the code to import the Link component from Next.js.
import [1] from 'next/link';
Next.js provides a Link component for client-side navigation.
Fix the error in this Next.js page export statement.
export [1] function About() { return <p>About page</p>; }
Next.js pages must export a default function component.
Fill both blanks to create a server component that fetches data.
export async function [1]() { const res = await fetch('/api/data'); const data = await res.[2](); return data; }
getServerSideProps fetches data on each request, and res.json() parses the response as JSON.
Fill all three blanks to create a Next.js API route handler.
export default function handler(req, res) {
if (req.method === '[1]') {
res.status([2]).json({ message: '[3]' });
} else {
res.status(405).end();
}
}This API route responds to GET requests with status 200 and a JSON message.
