next/router is a library provided by Next.js. Use this tag if you need help with the useRouter hook, the withRouter HOC, or with the extracted information from the router object.
Questions tagged [next-router]
293 questions
0
votes
1 answer
React ignoring Path causing wrong menu to show
I have a menu with white links for dark backgrounds (used on homepage) and menu with dark links used on every other page.
For whatever reason on production, react/NextJS just ignore this on first page load even though when I console the path is "/".…

lolitsme
- 7
- 3
0
votes
1 answer
import json into react app but it's undefined when accessing a nested field
I imported a json file into my react app (using next.js router), and need to access a field in it by a parameter in the URL. It works when I navigate from another page (/home -> /annotations/), but doesn't work when I refresh the page…

guckmalmensch
- 973
- 2
- 9
- 22
0
votes
0 answers
Next JS route is not resolving in production build
I have a following route pattern in the custom server of NextJs project. Everything works fine in the development. But in production build the route is not recognised and goes to 404 page.
Routes
{ name: 'business-with-key', pattern:…

sinthu225
- 301
- 3
- 16
0
votes
0 answers
How to read NEXTJS route from router.query if it was matched in to static page?
I would like to have static routes in my application while saving ability to read them somewhere.
For example:
-/Pages
--index.js
--/Account
---Settings.js
---[AccountPages].js
Somewhere in my codebase:
import { useRouter } from 'next/router'
const…

Peersky
- 115
- 7
0
votes
0 answers
How to change state while listen to the router change in Next.js?
What i'm trying to accomplish is exactly the same open and close menu animation while change router as this React app on github, but using Next.js(it's is pretty much the same code)
Here is my app repo on github, and here the app live.
I'm trying to…

Clovis Rosa
- 147
- 7
0
votes
0 answers
is there any way to convert react router to next router with login redirect?
I am working on shifting react js to next js, i am facing some issue in react router, supposed i have many dashboard route and those route must be pass though login , so i have to pass all the dashboard route though login, if user is not login than…

Koushik Saha
- 357
- 1
- 3
- 11
0
votes
0 answers
Next Js: URL is changing but page is empty
I am new in Next Js. Whenever I click on the link it updates the URL but the page is not showing any data. But in Elements data is present.
here is the code of nav file:
…

ammar
- 23
- 7
0
votes
1 answer
Next.js navbar: highlighting doesn't clear when clicking on link from different
I'm trying to implement a navbar with active links highlighting with Next.js (I am using React-bootstrap, too, for the record).
I tried to follow this guide, and some highlighting works, while other doesn't.
My Current Code:
CustomLink.jsx:
import {…

Guillermo Brachetta
- 3,857
- 3
- 18
- 36
0
votes
2 answers
NextJS useRouter error when used inside function body
I hope this is a simple question. I can't figure out why it's doing this. Anyways, using NextJS i'm trying to access the params in the router using the useRouter hook and combining it with the querystring plugin to split asPath, since NextJS doesn't…

sylargaf
- 346
- 1
- 6
- 19
0
votes
1 answer
Link tag just changes the url but not render the page
I'm trying to learn next js routing and encountered an error.
Every time I click the Link tag it just changes the url from "localhost:3000" to "localhost:3000/sample"
but it doesn't display the "Hi" on my sample.js file
import React from…
user13766435
0
votes
1 answer
Get product permalink and ID using Next JS and Commerce.js
I'm wondering if anybody can point me in the right direction. I'm following the dynamic routes documentation on Next JS site - https://nextjs.org/docs/routing/dynamic-routes
Currently I'm rendering all products on the products page. I'm using…

Joe
- 918
- 1
- 8
- 17
0
votes
0 answers
Dynamic Routing using Next.js and React Js
I am creating a Ecommerece application in React/Next Js. I want create dynamic routing with different peramaters for both product detail page and category page.
for Example if I click on category then its routing will be…

Jagveer Singh
- 355
- 1
- 4
- 14
0
votes
1 answer
Client-Side routing doesn't work between Dynamic Path Route
I don't know why It doesn't work.
When I have called router.push({ pathname: '/user/a' }) to go to /pages/user/[userId].tsx It routes by URL navigate.
But I router.push({ pathname: '/user/b' }) to go to /pages/user/b.tsx It routes by client-side.
I…

theodore han
- 27
- 5
0
votes
1 answer
Do a client side reload and change url in Next.js
I have the following code snippet in one of my Next js components -:
import { useRouter } from "next/router";
import Router from "next/router";
import { Menu } from "antd";
export default function AccountMenuList() {
const router = useRouter();
…

Mohit Kamal
- 53
- 5
0
votes
1 answer
Unexpected behaviour when use Next.js router push with URL object
According to the Next.js documentation, I can use the router push function with a URL object to route dynamic paths, like this example :
import { useRouter } from 'next/router'
export default function ReadMore({ post }) {
const router =…

Felipe Antero
- 43
- 1
- 7