Questions tagged [next-router]

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.

293 questions
1
vote
1 answer

I want to redirect a user in Next without using . React Router has useNavigate(), so does Next Router have anything similar?

I want to redirect users in NextJS similar to how you can use useNavigate(). is not good enough for this, because I want the user to be immediately redirected.
1
vote
0 answers

NextJs router seems very slow

The problem is about that is taking long time to response another route. It seems next router's error and it can cause by this ("getServerSideProps"). How can I change with this code to another or did I need to change react router instead? This is…
1
vote
0 answers

Why does using [element].click() on the client bypasses router in Next.JS?

We have a React application using Next.js. My understanding is NextLink works by adding a click event to the element, stopping normal navigation and letting the router handle it instead. For example: Go…
Scribblemacher
  • 1,518
  • 1
  • 16
  • 31
1
vote
1 answer

next/router different based on Dom element clicked?

I have been developing a darkmode/lightmode hook and system for my platform, using nextjs/react etc. I have come across a very strange issue where in certain circumstances I get a lightmode flicker when certain dom element types are clicked vs…
Brad Larson
  • 589
  • 5
  • 6
1
vote
1 answer

Next.js dynamic link with catch-all (ie. [[...slug]]) does not work when using the "as" prop in Link component

I am building a Next.js app where some of the pages have in-page-routes one them. To accommodate this, I am using a catch-all (i.e. [[...slug]]) and handling the routes on that page itself. My folder structure looks like this: While these routes…
1
vote
1 answer

How to route to page using Dynamic Routes in next.js

I am trying to route these urls to [id].js file in next.js, So everything is working for url 2 and 3 below, but its not working for url 1 so I have to create another index.js file which I dont want. Is is possible to use the same [id].js file? for…
Ashiq Dey
  • 309
  • 5
  • 18
1
vote
3 answers

Identify the page from where we are navigating to the resulting page in Next.js

Let's say there are three pages - A, B, and C. I can navigate from A to C and from B to C as well, but the view of C depends on the page from which we are navigating. I would like to know how we can identify in Next.js from which page we are routing…
1
vote
0 answers

isReady is true from next/route when using getInitialProps

In my application I'm using nextjs and I'm transition my app from static to SSR. On my custom App I introduced the getInitialProps function and I noticed that when I use getInitialProps function, my property isReady from the hook useRouter() is…
immags
  • 11
  • 1
  • 2
1
vote
0 answers

How push history router without change URL

For example I have a form with three steps. I want that each step are in the history router but without changing de URL Is it possible do it with Next Route or Next Link?
1
vote
1 answer

Nextjs, when clicking back, url update but not the content

I'm trying to figure out why when I click to the browser's back button or setting myself a button with a router.back, the url is updating but not the content? When I refresh the page, the content is updated et the console prints an error the error…
Rom-888
  • 681
  • 2
  • 9
  • 30
1
vote
0 answers

how to keep url query string values even on page refresh

I am using useRouter and Link, while navigating through my webapp. I attach query string to the links so that i can use the passed data of the query, in the page i am redirecting the user to. which works fine. however, on page reload / refresh, the…
1
vote
1 answer

Check User Visit the Url in nextjs

I want to check the if visit the page first time the function run else not run e.g.: very first time user open the site HOME page show the condition is must run after the user visit /about page the about page also first time condition run after this…
1
vote
0 answers

Displaying different Component based on the URL that the page is navigated from NextJS

I have two different pages one of them is the store page with products in it displayed with the ProductCard component and the other one is the category page with products, again with the ProductCard component. What I want to achieve is that when the…
Rinael
  • 133
  • 3
  • 12
1
vote
1 answer

next/link URL changing but page doesn't re-render

I have an odd problem where a dynamic link inside a component works in most places on the site (static pages), but not inside a particular React Component - Algolia InstantSearch (functionally very similar to this component:…
1
vote
0 answers

Next.js :Uncaught (in promise) Error: The provided `href` (/confirmation/[token]) value is missing query values (token) to be interpolated properly

Not sure how to resolve this error, as the docs mention a Link tag: Why This Error Occurred Somewhere you are utilizing the next/link component, Router#push, or Router#replace with href interpolation to build dynamic routes but did not provide all…
Antonio Pavicevac-Ortiz
  • 7,239
  • 17
  • 68
  • 141