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 + Sanity. Getting 404 error when using next/link or next/router
Getting 404 error when go to project page
router.js:250 GET http://localhost:3000/_next/data/development/en/projects/missing-middle.json?slug=missing-middle 404 (Not Found)
When reload project page it looks fine.
Structures of sanity and…
0
votes
0 answers
i have next.js13 component,using router.push to create a url, I want to immediately access the params on the app/quote/page.js to compose message
Here is my ServicesGridComponent() ---> It creates a url: http://localhost:3000/quote_form?id=undefined&service=Gardening --> the service.id is undefined?
'use client';
import { useRouter, useState } from 'next/navigation';
import ServiceCard from…
0
votes
0 answers
NextJS redirects not applied to client-side routing
I'm working on a NextJS project and trying to set up redirects and rewrites because I'm working with multiple locales. Redirects work correctly when entering URLs manually but do not work with internal links or "router.push" functions. I followed…

Manon
- 329
- 1
- 8
0
votes
0 answers
Next.js 13... Cannot pass down a queryid to the url using next/navigation but get all all the other parameters
I am using next/router to build the url but in the url serviceId?=undefined
'use client';
import { useRouter, useState } from 'next/navigation';
import ServiceCard from './ServiceCard';
const ServicesGrid = ({ servicesArray }) => {
const router =…
0
votes
0 answers
How do I redirect a user to a new page using url containing Id in nextJs
I'm new nextJs & I need help creating an URL for redirecting to a detail page that includes a id as part of the URL after an onclick event is triggered, below is my code
Import {Router} from 'next'
const router = Router
const redirect =(id)=>{
…

Tosin Ayoola
- 77
- 1
- 9
0
votes
0 answers
Retrieving data from next/router and local storage
I'm trying to create a social media app as a project. I have two pages: posts.js and [id].js.
posts.js
{
router.push({ pathname : `/user/${props.user._id}`})
}}
>
When user clicks…
Unnikrishnan KJ
- 53
- 7
0
votes
0 answers
Dynamic routing in nextjs 13
I want to develop a route which catches multiple parameters in a single route in nextjs 13 for SEO.
One of the sample route is:
/how-to-decide-which-{profession}-to-choose-after-{degree}
I have checked the documentation of nextjs 13 and did not…

Aditya
- 362
- 2
- 12
0
votes
1 answer
Change in the order of hooks when calling API inside useEffect
I have the following component:
const PostPage = () => {
const [post, setPost] = useState(null);
const [comments, setComments] = useState([]);
const router = useRouter()
useEffect(() => {
if (router.isReady) {
…

kirill ras
- 3
- 1
0
votes
1 answer
Next js dynamic routing isues with states and categories
I am working on complex routing in Next js and I am not able to find a way how can I set up it. In an e-commerce store that is based on the shop and tailormade catalog with USA states(al,ak, az). solutions .So the URL should look like…

Raghwendra Ojha
- 11
- 1
- 8
0
votes
0 answers
I have an issue in my nextjs app with API's files and router.push, the router.push("/mi-cuenta") line works fine in local but no in prod
This block executes when I submit the login form, if all is ok (status 200) it should push the navigation to "/mi-cuenta" page, this works fine in local but no in production, I have no evident bug or error thrown. I'm using auth and middleware to…

LET1S3N
- 28
- 7
0
votes
0 answers
router.push changes url but doesn't redirects
I'm having trouble with router.push in next js. Sometimes, when I do it, it changes the URL but do not redirects to the desire page...
I'm using 13.0.5 pages directory.
For example, I do this:
import { useRouter } from "next/router";
(...)
const…

Emiliano
- 437
- 1
- 4
- 14
0
votes
0 answers
Params are undefined in use client component in next 13
I have a Next.js project with a dynamic route for the donate page. In a separate HTML file, I passed the URL to an iframe and attempted to pass query parameters from there. However, I am facing an issue as I am unable to receive the query…

sohaib
- 574
- 5
- 16
0
votes
0 answers
Next.JS Link forces page reload on routing if internet connection is slow
I have a React Next.js application, and I use Next.js components for routing.
Everything works just perfect, unless the internet connection is getting slow.
Reproduced by throttling network in browser dev tools.
If connection is slow, and you click…

Mikhail Figurin
- 1
- 2
0
votes
0 answers
Next js 13 data passing between pages
I have a button in a page. When I click on the button I want to redirect to another page and send some data. The page is client side component. I'm using nextjs version 13.4.9. Is that possible?
Main Page
const btnHandler = () => {
// redirect to…

Ibnul
- 1
- 1
0
votes
1 answer
useEffect hook for login via local storage
I'm creating a React + Next.js app with authorisation and I need to get token from local storage. If I do this without useEffect, there is an error of undefined localstorage, but with use effect my redirects don't work, maybe you know where am I…

Evan Serg
- 27
- 5