Complete the code to create a page component in Next.js that will be automatically routed.
export default function [1]() { return <h1>Home Page</h1>; }
In Next.js, the default export of a file inside the app or pages folder is the component rendered for that route. Naming the function Page is a common convention in the app directory.
Complete the code to create a nested route by placing a file in the correct folder.
app/[1]/page.js export default function Page() { return <h1>About Us</h1>; }
In Next.js file-based routing, placing a page.js inside a folder named about creates the /about route automatically.
Fix the error in the code to correctly link to the About page using Next.js navigation.
import Link from 'next/link'; export default function Home() { return ( <nav> <Link href=[1]>About</Link> </nav> ); }
In Next.js, the href prop in Link should be the absolute path starting with a slash and matching the folder name exactly in lowercase.
Fill both blanks to create a dynamic route for user profiles in Next.js.
app/users/[1]/page.js export default function Page({ params }) { return <h1>User ID: {params.[2]</h1>; }
Dynamic routes in Next.js use square brackets in folder names like [id]. The parameter is accessed via params.id.
Fill all three blanks to create a nested dynamic route and display both parameters in Next.js.
app/blog/[1]/[2]/page.js export default function Page({ params }) { return ( <> <h1>Category: {params.[3]</h1> <h2>Post: {params.postId}</h2> </> ); }
For nested dynamic routes, folders use square brackets like [category] and [postId]. The param names match the folder names without brackets.