Accessing Route Parameters: Inside the page component, you can use the useRouter hook provided by Next.js to access the dynamic route parameter. Here’s how you can do it:
import { useRouter } from 'next/router';
const UserPage = () => {
const router = useRouter();
const { userId } = router.query; // This is how you access the userId
return (
<div>
<h1>User ID: {userId}</h1>
</div>
);
};
export default UserPage;