Next.js Discord

Discord Forum

next dynamic routing

Unanswered
Varun posted this in #help-forum
Open in Discord
'use client'
import { useRouter } from 'next/navigation';

export default function Page() {
const router = useRouter();

console.log(router.query)
const draftId = router.query.draftId;



return (
<div>
<p>Draft ID: {draftId}</p>
</div>
);
}

I am getting the error in the image. When I check router.isReady, it is also false. Any ideas?

5 Replies

Tonkinese
If you're using the app directory, the draftId is automatically passed in as a param prop to the page component.
@Varun try using the useParam() instead
ah ok cool
that works thx
yea some docs are a bit outdated