Answer the question
In order to leave comments, you need to log in
How to find out where the user came to the site?
I'm working on a project written in Next JS, I need to make a "go back" button, but provided that a person got to the page through our site, if through a third-party it throws them to the main page, this is so as not to lose the user.
I tried to write this code.
const handleUrlFromGoToSite = () => {
if(!document.referrer.includes('mysait-url')) {
Router.push('/');
}
else Router.back()
};
Answer the question
In order to leave comments, you need to log in
Come here , it might help.
This is done in PHP, you are unlikely to do it in JS.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question