How can I get history in NextJS? Or just Focus on item I redirected user from when he comes back

I need to focus on the item my user was redirected from to details page when he comes back. To do so I figured I need to have focus func in my general info page (/users/) and focus if someone is redirected to it from details page (/user/{id}). Do I need to get that id to focus on that item?
9 Replies
Neto
Neto3y ago
you can pass a query param no? /user/{id}?focus=something as example
Patryk Makowski
Patryk MakowskiOP3y ago
I thought about that before but I don't like it that much. Although it solves the issue for sure I thought I could do it without URL params
Neto
Neto3y ago
you can maybe check the history api from the browser
Patryk Makowski
Patryk MakowskiOP3y ago
Already done, no luck :c I can write my own history context and use that but I feel like this is over engineering
Neto
Neto3y ago
maybe proxy the link and add to local storage? switch from using the next link directly to a onClick with a custom function add to local storage and push to next link
Patryk Makowski
Patryk MakowskiOP3y ago
GitHub
Retrieve previous route and/or route history in Next router · Discu...
I'm using the router you can retrieve from arguments in _app. In router.route, there is a state object identical with what is shown here (docs). Nowhere do I see any mention of past route r...
Patryk Makowski
Patryk MakowskiOP3y ago
I found this but I can wrap my head around this, How am I supposed to implement this?
Neto
Neto3y ago
let me try it i think i did it https://next-history.vercel.app
Neto
Neto3y ago
GitHub
GitHub - STNeto1/next-history: next-history
next-history. Contribute to STNeto1/next-history development by creating an account on GitHub.
Want results from more Discord servers?
Add your server