import {useRouter} from 'next/navigation' Data Type
Unanswered
West African Lion posted this in #help-forum
West African LionOP
What is the data type for useRouter in 'next/navigation'? I need to know because I am passing a router object as a prop and I am using typescript. Thank you.
6 Replies
Birman
Should be
NextRouter@Birman Should be `NextRouter`
West African LionOP
I am using the new App Router... apparently cannot use useRouter from next/router with it... need to use useRouter from next/navigation instead.
Birman
You should probably be using
withRouter instead@West African Lion What is the data type for useRouter in 'next/navigation'? I need to know because I am passing a router object as a prop and I am using typescript. Thank you.
You shouldn't be passing the router as a prop, atleast not in app router
If you want to use the router on a component, simply declare it in that component.