Complete the code to import the Next.js Image component.
import [1] from 'next/image';
The Next.js Image component is imported as Image from 'next/image'.
Complete the code to export a Next.js page component as default.
export default function [1]() { return <div>Hello</div>; }
By convention, Next.js page components are often named Home or relevant to the page. Here, Home is used.
Fix the error in the Next.js page component export statement.
export [1] function Home() { return <main>Welcome</main>; }
Next.js pages must be exported as default exports. Adding default fixes the error.
Fill both blanks to create a Next.js API route handler that sends a JSON response.
export default function handler(req, res) { res.[1]({ message: '[2]' }); }The res.json() method sends a JSON response. The message string is 'Hello World'.
Fill all three blanks to create a Next.js page that fetches data server-side and displays it.
export async function [1]() { const res = await fetch('[2]'); const data = await res.[3](); return { props: { data } }; }
getServerSideProps fetches data at request time. The URL is 'https://api.example.com/data'. The response is parsed as JSON with res.json().