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
0 answers
Next js conflict between dynamic pages with nested routes and fixed pages
I have dynamic pages with nested routes and fixed pages in the pages folder for example
The name of the page is dynamic
pages/[model]/[slug]
fixed name
pages/about
so in this way what is the best solution

faruk
- 141
- 6
0
votes
1 answer
Nextjs routing issue: superior param is weird
I have a project using nextjs v12
I have 2 routes that are overlapping in a weird way.
/:academy/:course
/questions/:id
when I load /questions/1 it works as expected
when I load /mit/math it works as expected
The issue:
when I redirect from…

Post Malone
- 72
- 9
0
votes
0 answers
How to reduce SSR loading time in Next JS?
I am trying to reduce the load time that SSR is taking right now, So, I am building a property page
I have a next link that takes me to that property page but it takes too much time so it seems the API takes too much time so how can I reduce the…

karamat ali
- 1
- 1
0
votes
0 answers
(Next.js) Passing state object from an array mapping to router query when rerouting. TypeError: Cannot read properties of undefined (reading 'name')
How do I pass each coin being mapped through to state so when routed to the CoinInfo.jsx page I can pass 'coin' as a prop when calling sendProps in CoinSearch.jsx. So I can have access to the the coin's attributes on the CoinInfo page and can…

mason
- 1
- 1
0
votes
0 answers
Prevent refetching data when resetting redux state on a reroute with next-router
I currently have this piece of code:
const handleClick = async () => {
dispatch(resetFilters());
if (router.pathname !== '/') {
await router.push('/');
}
};
Where resetFilters() is a function to reset all the state in a…

Jorgen
- 93
- 1
- 8
0
votes
1 answer
TinaCMS/Nextjs github pages 404 when accessing root url in
I just deployed a TinaCMS page on github pages using github actions. It seems to work fine except on initial access to the root URL. On this initial load, Nextjs renders a 404 error page with a link 'Return to home'. When clicking this link, the…

user1727870
- 121
- 7
0
votes
0 answers
Link in NextJs appends to current path but want to replace
Let's say the current url looks like this: localhost:3000/foo/hello and hello being a dynamic route.
I have a Link Component with href={'/something/test'} and when clicking it I want to get to: localhost:3000/something/test, with test being a…

Allleex
- 137
- 9
0
votes
0 answers
Templating in Next JS in another level that _app
Just like we have _app.tsx and we can receive a Component in props dynamically according to the route, can we have another page at a different level with the same kind of functionality?
Here is an example of what I require:
My App page has a static…

Kashif Nazar
- 20,775
- 5
- 29
- 46
0
votes
1 answer
How to configure between pages role control automation in Next.js?
enter image description here
every time the route information changes, it should get the user's role information and then check it before going to the page he wants to go to.
If the permissions of the page and the user role match, it should load the…

Enes Gülcü
- 17
- 5
0
votes
0 answers
Confusing behavior from router.push() from useRouter in NextJS
I'm trying to implement a redirect using push() from useRouter and getting confusing behavior. My use case is simple: after a user signs in, I want to call router.push('/') to send them to the home page. However, calling router.push('/') after…

rolias4031
- 233
- 2
- 10
0
votes
0 answers
Passing nested data via router.query in next.js resulting in " " on the nested data
Before I pass my data to my query, the user's data is complete and it has all the data but when it's passed on the receiving url, it's missing some data.
I passed the data like this
href={{ pathname: "/update/" + user.id, query: user, }}
And…
0
votes
1 answer
How to navigate correctly in nextjs
idk it's pretty simple or what but having difficulty understanding it.
here is one parent div wrapped with nextjs Link tag(which navigates me to /playing route) and in this div i have one more tag which can navigate me to login page. here is the…

Ansh Rathod
- 55
- 8
0
votes
0 answers
Pass Function to Page in Next Js
i am working on next js project in which i had to add email verification functionality. the client requirement is that when user click on submit button it refers to email verification and after verifying the email it should have dynamic behavior (…

Arslan Ahmad
- 11
- 2
0
votes
0 answers
Get pathname without id (Next.js)
Is there any way to get the path in the next.js router without an id? When I use router.pathname I get a path like: "/product/id" Is there any way to get a path without th id: "/product" I can do it that way:
`/${pathname.split('/')[1]}` // …

Lex2000
- 155
- 1
- 1
- 12
0
votes
1 answer
Nextjs routing in react - render a page if the user is authenticated
I'm trying to figure out how to set up a nextjs index.tsx page, that renders a page if the user is authenticated and another component if the user is not authenticated.
I can have the not authenticated component rendered properly, but I cannot have…

Mel
- 2,481
- 26
- 113
- 273