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 Link works correctly in desktop view but not in mobile view
I have one vertical navbar. When the width falls below 951 pixels, I take this navbar from the verticalnavbar class and throw it into the nav-links in my navbar class to provide a hamburger view. There is no problem in transferring, but the Link…

Selim Başpınar
- 11
- 1
0
votes
2 answers
How to send a unique id to the next page while navigating using Link in NextJS
I am trying to send an id to the next page when the user navigates.
I have a homepage where I am fetching an Array of data and using .map to display it in a kind of card-based UI.
Now, when the user clicks the card, they will be navigated to the…

anshul
- 661
- 9
- 27
0
votes
0 answers
NextJS routing path opening on iframe parent window
I have search page that contain a form and I'm using iframe to load that page on my main site. I need to this because my main site is on squarespace and the search functionality is written on react and hosted on vercel. The problem is when I search,…

Whiz
- 33
- 6
0
votes
1 answer
Remembering the URL a user was trying to access when redirected to Login page in Next.Js
What I'm trying to do: If a user tried to go to the URL some-basepath/events/632dbb3f6852f but was not authenticated, I want to be redirected to something like some-basepath/login?redirect=events%2F632dbb3f6852f & after signing in, I should be taken…

Daniel_Kamel
- 610
- 8
- 29
0
votes
2 answers
How to pass data between components with next.js?
I have a next js project and I want to pass data between components. This is my data:
const data = {
eventName: "FIVB Volleyball Women's World Championship ",
eventDate: "13-09-2022 / 20-09-2022",
eventLocation: [
{
…

Gözde
- 25
- 5
0
votes
1 answer
How to add queryPrams with previous query into next js router?
here suppose I have a dynamic router like [index] under category folder. Here dynamic index will be category slug. Now I have to add more query prams in this url.
First link will be like-
/category/men-and-women
Now I have to add to this url some…

Md Ali
- 217
- 1
- 2
- 10
0
votes
0 answers
Fallback-page of getStaticProps won't open when redirecting to the page by useRouter()
I have the following problem:
I have a page in my Next.js Project and use getStaticProps for this page to preload data. Since this takes some seconds, I created a fallback page that is shown during this process.
If I enter the link to this page…

Luca
- 3
- 2
0
votes
1 answer
Navigate to other page on API response in next
I have one function called postAPI which is common function to send any request to back end server in my next app.
import Router from 'next/router';
export const postAPI = async (
endpoint,
data = {},
headers = {},
method = 'POST',
options…

Drashti Kheni
- 1,065
- 9
- 23
0
votes
0 answers
Next JS next/link, not working in the initial page load
Hope all are doing good. I will directly move to the issue, I am trying to migrate my React-Typescript to Next JS for routing purpose. I am using Link -next/link but it is not working when the server is started but after a refresh routing is working…

MONEYMSN
- 69
- 9
0
votes
0 answers
Get previous two URLs from next router object
this is my code:
import { useRouter } from 'next/router'
const App = () => {
const router = useRouter()
return null
}
router object has NextRouter type. However, this type don't have components property, whereas runtime value has.
So,…

captain-yossarian from Ukraine
- 31,174
- 3
- 30
- 62
0
votes
1 answer
How to include useRouter in function from one place with Next.js?
I have a function in Next.js project that collects events for Firebase analytics.
import analytics from '@utility/firebase';
const handleLogEvents = (event) => {
const currentDate = new Date();
logEvent(analytics, event.event_name, {
…

Caner
- 504
- 3
- 17
0
votes
1 answer
NextJS: 404 when coming from browser to subpath
I deployed my NextJS app as a static website on my own server and it's working well. Except that if I try to access a page that is not the main page through typing the url in the browser, I get a 404. (When I come from the navigation within the app,…

Cioccoluna
- 27
- 2
- 15
0
votes
1 answer
Can I use Next.js Link to navigate from slug page to the default one?
So I have the default page and some 'slug' dynamic pages, the urls look like this:
default page locally: localhost:3000/doc/default
slug page locally: localhost:3000/doc/[slug]
default page in production: default.com/doc
slug page in production:…

kbo
- 422
- 5
- 17
0
votes
1 answer
Dynamic routing gives an error when updating the page Next.js
Tell me, there is a problem with dynamic routing. When I click on the link /card/[id] . Then everything works correctly, the id of this card is attached to the path that I clicked on, but if I try to refresh the page after the transition, then I get…

XAZG Неизвестный
- 101
- 1
- 11
0
votes
1 answer
How do I dynamically create route using a function return in next.js
I am trying to create a simple multiplayer game. I want to use a randomly generated room id in the route in order to route to the newly created lobby but can not pass the functions return to router.push as query ; I don't know why? Can you help…

no-syntax-cobol
- 35
- 4