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
0
votes
1 answer

How do I push user to another page using a button in Nextjs?

I am trying to redirect a user on a button click in my nextjs app, pls how do I accomplish this?
Paulliano
  • 347
  • 1
  • 5
  • 15
0
votes
1 answer

nextJS nested Routes for multiple slug cases

Hello everyone I have a problem regarding nextJS routing i have the following folder structure and its works fine for a simple scenario where a project has only one folder and this folder have one domain but my problem occurs when a project has a…
Ali Berro
  • 11
  • 1
  • 2
0
votes
2 answers

Change the state of a component on route change - NextJS

I'm trying to change the background on an element on click on a specific route using the useState hook. The background of element is changed but it has been changed on the other pages as well. Is there any way that the background of the element can…
0xMukesh
  • 447
  • 1
  • 7
  • 10
0
votes
0 answers

Pass additional data to next router in router.push

Is it possible in next/router to pass some additional data to the next route with router.push? For example, router.push('/my-route', { custom: { displayError: true } }); Obviously, I added that custom, but that's the behaviour I…
AngularDebutant
  • 1,436
  • 5
  • 19
  • 41
0
votes
0 answers

How to handle router.back in Nextjs while using internationalisation?

I'm trying to use the router.back(), but I'm also using i18n localization. I start at the Home page which is "localhost/" and navigate to "localhost/auth/sign-in". Now on changing the language (which has its specific route)…
0
votes
0 answers

Next.js router params keeps giving me unknown key warnings

Im creating a search page so I am using the URL params to handle the filters, such as product category and price. This is my current method that handles adding and removing the URL params: function handleCheck(checked: Boolean, id: string, option)…
squish
  • 846
  • 12
  • 24
0
votes
1 answer

Next.js Dynamic Route With a User Inputted URL

I am using the Next.js Router to enable different dashboards depending on the URL slug. This works when a button with the link is clicked, as the link passes the information to the Next.js Router, but it does not work when a URL is inputted directly…
Redneys
  • 285
  • 1
  • 6
  • 18
0
votes
0 answers

Can [parameters] be inserted dynamically into paths in Next.js?

I'm running into a problem trying to get routes working with [params]/:params. The paths I'm working with will always be structured as follows: console/sites/[siteId]/possibly-another-directory/page. The console/sites portion I can set as basePath…
flyingace
  • 1,707
  • 17
  • 24
0
votes
0 answers

Persistent Layouts in Next.Js using HOC

Background to the problem HOCs When dealing with Next.Js pages a common practice is to use HOC (Higher-Order Component) to avoid retyping the base of a page. For example, an authentication HOC can be used to check if a user is authenticated or not.…
Gnusson
  • 305
  • 1
  • 2
  • 9
0
votes
1 answer

How to dynamically update query in next/router jest.mock

Is there a way to dynamically update a next/router/ jest.mock query? I am essentially trying to mock a different query depending on the tests that are run. i.e. jest.mock('next/router', () => ({ useRouter() { return { …
user6248190
  • 1,233
  • 2
  • 16
  • 31
0
votes
1 answer

NextJS, how to upload a server-side rendered application to my FTP account

I appreciate all of your help. I like how create-react-app allows you to run NPM RUN BUILD and then upload the "Build" folder to your FTP directory. How is this possible with NextJS? I built my app and ran NPM RUN BUILD, but do not see a Build…
0
votes
0 answers

Router.back() won't work in incognito mode or when link comes from different source

i am using Nextjs as react framework for my ecommerce website. My product detail page have an custom back button which is having Router.back() function. This works normal when browsing back and forth in website. But whenever i copy the product…
Gurupal singh
  • 136
  • 1
  • 3
  • 10
0
votes
0 answers

how to link to page in Next.js with locale when project is in subdirectory?

I have a problem with routing in next.js. Project on the server is in subdirectory: exmaple.com/app. Routing i want to achieve: example.com/app// (add prefix before url). When I'm trying to add it in href Link generates url this…
0
votes
2 answers

How to show loading state only if data is not received yet. Next.js ssr

I have multiple getServerSideProps in my project and I have a header which displays pages and I have to wait for a page to be opened once I click upon it since I need data to be fetched. Once they are fetched the page will be open. One approach I…
Rostyk
  • 939
  • 3
  • 13
  • 32
0
votes
2 answers

How can display pages with different states based on query parameters in next.js

I want to display pages with different states based on different query params in next.js , so that when a user uses a link with query param , It should not show the default page , but based on the state. For simplicity Coinsider the home page as …
Hussam Khatib
  • 600
  • 6
  • 17