Complete the code to import the Next.js Link component correctly.
import [1] from 'next/link';
The Next.js Link component must be imported with the exact name Link to work properly.
Complete the code to create a functional component that returns a main HTML element.
export default function Home() {
return <[1]>Welcome to Next.js!</[1]>;
}div instead of semantic elements.Using the main element improves accessibility by indicating the main content area.
Fix the error in the Next.js page component by completing the export statement correctly.
function About() {
return <p>About us page</p>;
}
export default [1];The component name About must be exported exactly as declared, without parentheses.
Fill both blanks to create a reusable button component with a click handler.
export function Button({ onClick }) {
return <button [1]=[2]>Click me</button>;
}The button element uses the onClick attribute to handle clicks, and the handler function is passed as the onClick prop.
Fill all three blanks to create a Next.js page that fetches data server-side and displays it.
import [1] from 'next'; export const getServerSideProps: [2] = async () => { const res = await fetch('https://api.example.com/data'); const data = await res.json(); return { props: { data } }; }; export default function Page({ data }) { return <pre>{JSON.stringify([3], null, 2)}</pre>; }
GetServerSideProps is the correct type for the server-side props function, and data is the prop passed to the component to display.