0
0
NextJSframework~10 mins

Why Next.js navigation is optimized - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Next.js navigation hook.

NextJS
import { [1] } from 'next/navigation';
Drag options to blanks, or click blank then click option'
AuseNavigate
BusePathname
CuseRouter
DuseSearchParams
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing Next.js hooks with React Router hooks.
2fill in blank
medium

Complete the code to navigate programmatically to the home page.

NextJS
const router = useRouter();

function goHome() {
  router.[1]('/');
}
Drag options to blanks, or click blank then click option'
Ago
Bnavigate
Cpush
Dredirect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'navigate' which is not a Next.js router method.
3fill in blank
hard

Fix the error in this code that prefetches a page for faster navigation.

NextJS
useEffect(() => {
  router.[1]('/about');
}, []);
Drag options to blanks, or click blank then click option'
Aprefetch
Breload
Creplace
Dpush
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'push' instead of 'prefetch' causes immediate navigation.
4fill in blank
hard

Fill both blanks to create a link that prefetches and navigates on click.

NextJS
<Link href="/contact" [1]=[2]>Contact Us</Link>
Drag options to blanks, or click blank then click option'
Aprefetch
Btrue
Cfalse
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'false' disables prefetching.
5fill in blank
hard

Fill all three blanks to explain why Next.js navigation is optimized.

NextJS
Next.js uses [1] to load pages in the background, [2] navigation without full reloads, and [3] caching for faster repeat visits.
Drag options to blanks, or click blank then click option'
Aprefetching
Bclient-side
Csmart
Dserver-side
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing server-side with client-side navigation.