Next.js Discord

Discord Forum

import {useRouter} from 'next/navigation' Data Type

Unanswered
West African Lion posted this in #help-forum
Open in Discord
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
If you want to use the router on a component, simply declare it in that component.