0
0
NextJSframework~20 mins

Link component for client navigation in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Next.js Link Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when you click this Next.js Link?
Consider this Next.js component using the Link component for navigation. What will the user experience when clicking the link?
NextJS
import Link from 'next/link';

export default function Home() {
  return (
    <div>
      <Link href="/about">
        <a>About Us</a>
      </Link>
    </div>
  );
}
AThe page navigates to /about without a full page reload, preserving client state.
BThe page reloads completely and then navigates to /about.
CNothing happens because the Link component is missing a required prop.
DThe browser opens /about in a new tab.
Attempts:
2 left
💡 Hint
Think about how Next.js Link handles navigation internally.
📝 Syntax
intermediate
2:00remaining
Which Link usage is syntactically correct in Next.js 14+?
Next.js 14 introduced changes to the Link component. Which option shows the correct way to use Link for client navigation?
A<Link href="/contact">Contact</Link>
B<Link href="/contact"><a>Contact</a></Link>
C<Link to="/contact">Contact</Link>
D<Link url="/contact">Contact</Link>
Attempts:
2 left
💡 Hint
Check the prop name and whether an anchor tag is needed inside Link.
🔧 Debug
advanced
2:00remaining
Why does this Link cause a full page reload?
This Next.js component uses Link but clicking the link reloads the whole page. What is the cause?
NextJS
import Link from 'next/link';

export default function Nav() {
  return (
    <nav>
      <Link href="/blog">
        <button>Blog</button>
      </Link>
    </nav>
  );
}
AThe href prop is missing, so Link falls back to full reload.
BUsing a button inside Link causes the browser to treat it as a normal button, triggering full reload.
CLink requires an anchor tag inside to prevent full reload.
DThe Link component must wrap only text nodes, not elements.
Attempts:
2 left
💡 Hint
Think about what HTML elements Link expects inside for client navigation.
state_output
advanced
2:00remaining
What is the value of count after navigating with this Link?
Given this component with state and a Link, what is the value of count after clicking the link and navigating back?
NextJS
import { useState } from 'react';
import Link from 'next/link';

export default function Counter() {
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
      <Link href="/other">Go to Other</Link>
    </div>
  );
}
AThe count increments automatically when navigating back.
BThe count value is preserved because Next.js caches the state.
CThe count value becomes undefined after navigation.
DThe count resets to 0 after navigating back because the component unmounts and remounts.
Attempts:
2 left
💡 Hint
Consider how React state behaves when navigating between pages in Next.js.
🧠 Conceptual
expert
2:00remaining
Which statement about Next.js Link prefetching is true?
Next.js Link can prefetch pages for faster navigation. Which option correctly describes how prefetching works?
APrefetching only works if the Link uses an anchor tag inside.
BPrefetching disables client-side navigation and forces full reloads.
CPrefetching loads the linked page's JavaScript and data in the background before navigation happens.
DPrefetching requires manual calls to a prefetch method after Link renders.
Attempts:
2 left
💡 Hint
Think about how Next.js improves navigation speed with Link.