0

I need user history for some redirection. How can I access it? If I couldn't there are the best practices to store the user history in my app.

kursademirtas
  • 17
  • 1
  • 2
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 15 '21 at 11:14
  • Does this answer your question: [How to get the previous URL in JavaScript?](https://stackoverflow.com/questions/3528324/how-to-get-the-previous-url-in-javascript)? In some cases you can use `document.referrer`. Otherwise, you'll need to implement your own logic to keep track of the visited pages. – juliomalves Nov 15 '21 at 22:14

2 Answers2

0

Accessing browser history is not directly linked with NextJS. If you want to access browser history, you can directly access it with window history object (Browser Object Model).

Arun
  • 56
  • 1
-1

In Nextjs use nextjs router hook for handling redirections.

Also you can use window or document browser objects, but make sure they are client rendered instead of server, as they will be undefined in server.

more you can read here

abhikumar22
  • 1,764
  • 2
  • 11
  • 24