Next.js · Junior · Question 51 of 75
How does a client component read the [slug] segment of the current URL?
'use client'
import { useParams } from 'next/navigation'
export function ShareButton() {
const { slug } = useParams<{ slug: string }>()
}- ✓Correct answer: With the
useParamshook fromnext/navigation - 2Client components can't access route params at all
- 3By reading
window.params
Explanation
Pages and layouts get params as a prop (a Promise in Next.js 16), while deeply nested client components can call useParams() instead of receiving params through props.