Definitelytyped: [@types/next] Property `push` not found in SingletonRouter

Created on 19 Jun 2018  路  3Comments  路  Source: DefinitelyTyped/DefinitelyTyped

In the nextjs docs under the imperative routing example, there is a usage of Router.push('about-url')

But when using typescript, there is an error saying Property 'push' does not exist on type SingletonRouter. Sample snippet as follows:

import Router from 'next/router'

Router.push('/url') // <--- error

The SingletonRouter has nested router property in order to use the push like Router.router.push.

@Dru89 @brikou

Most helpful comment

I'm having this issue with "@types/next": "^9.0.0",

Property 'push' does not exist on type 'typeof Router'.ts(2339)

All 3 comments

Solved after upgrading to v6.0.1

I'm having this issue with "@types/next": "^9.0.0",

Property 'push' does not exist on type 'typeof Router'.ts(2339)

I also have the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alisabzevari picture alisabzevari  路  3Comments

stevermeister picture stevermeister  路  3Comments

JWT
svipas picture svipas  路  3Comments

Loghorn picture Loghorn  路  3Comments

demisx picture demisx  路  3Comments