Challenge - 5 Problems
Next.js Navigation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why does Next.js prefetch links by default?
Next.js automatically prefetches linked pages in the background. What is the main benefit of this behavior?
Attempts:
2 left
💡 Hint
Think about how loading pages before clicking affects user experience.
✗ Incorrect
Next.js prefetches linked pages to load their code and data in the background. This makes navigation feel instant because the page is ready when clicked.
❓ component_behavior
intermediate2:00remaining
What happens when using Next.js for navigation?
Consider a Next.js app using the component for navigation. What is the main behavior difference compared to a normal tag?
NextJS
<Link href="/about">About</Link>Attempts:
2 left
💡 Hint
Think about how single-page apps handle navigation.
✗ Incorrect
The Next.js component intercepts clicks and loads pages client-side, avoiding full reloads and making navigation faster.
❓ state_output
advanced2:00remaining
What is the output when navigating with Next.js router.push?
Given this code snippet, what will be the value of
router.asPath immediately after calling router.push('/contact')?NextJS
import { useRouter } from 'next/router'; function Nav() { const router = useRouter(); function goContact() { router.push('/contact'); console.log(router.asPath); } return <button onClick={goContact}>Go Contact</button>; }
Attempts:
2 left
💡 Hint
Consider if router.push is synchronous or asynchronous.
✗ Incorrect
The router.push method is asynchronous. The router.asPath does not update immediately after calling it, so it still shows the old path.
📝 Syntax
advanced2:00remaining
Which Next.js navigation code snippet correctly prefetches a page?
Select the code snippet that correctly enables prefetching for a Next.js component.
Attempts:
2 left
💡 Hint
Check the correct way to pass boolean props in JSX.
✗ Incorrect
In JSX, boolean props can be passed as prefetch (which is equivalent to true) or prefetch={true} to enable them explicitly. Option C is incorrect because passing a string "true" is not the correct way.
🔧 Debug
expert2:00remaining
Why does this Next.js navigation cause a full page reload?
This Next.js app uses Profile for navigation instead of . What is the main reason this causes a full page reload?
NextJS
<a href="/profile">Profile</a>Attempts:
2 left
💡 Hint
Think about how Next.js handles navigation with and without .