Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
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 to page C.

Page C has a dynamic route

TIA

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could pass the previous location as query data:

<Link
          href={{
            pathname: "/some-page",
            query: "current location", // the data
          }}
>
         <a>Some Text</a> 
</Link>

Then you can retrieve the query data:

const router = useRouter();
const data = router.query;

If you don't like the idea of passing the previous location as a query, you could save the current location in a global state, like Redux on a page mount, after reading the previous value, which represents the previous location pathname.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!