When I try to redirect using Router.push()
I get the following error:
TypeError: next_router__WEBPACK_IMPORTED_MODULE_3__.Router.push is not a function
I am trying to migrate from create-react-app to next js.
const redirectUser = () => {
if (redirectToSignin) {
Router.push({
pathname: "/user/signin",
query: { message: "Please signin to view profile" }
});
}
};
Not sure what's going on here. Please follow the issue template and provide a full reproduction.
I had to import like so:
// works
import Router from "next/router";
// dont
import { Router } from "next/router";
Most helpful comment
I had to import like so: