Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Next.js app router (nextjs 13,14,15) #423

Open
JannikZed opened this issue Sep 17, 2024 · 1 comment
Open

Usage with Next.js app router (nextjs 13,14,15) #423

JannikZed opened this issue Sep 17, 2024 · 1 comment

Comments

@JannikZed
Copy link

Describe the bug
We are having a hard time getting walker.js running with next.js 15 and the app router. We created a client component and trying to start walker like that:

export const ElbWalker: React.FC<WalkerOSProps> = ({ customerId }) => {
  const location = usePathname();
  useEffect(() => {
    setupAnalytics(customerId);
  }, [location]);

  return undefined;
};

but it seems like the pathname update gets already triggered even when the page has not been loaded completely, which results in the triggering of the same event multiple times... we are trying to debug that, but currently can't really explain the behaviour.

Let's say I have an e-commerce item page. When I first load the page, the view_item event gets triggered and it is fine. When I make a local page transition to the /cart page, I see another time the view_item event being triggered, but not the view_cart event. When loading the cart page, I get the view_cart event being triggered just one time.

We are using the most recent version of the walker.js.

Are there any configuration settings for Next.js that we can follow?

@JannikZed
Copy link
Author

the main issue with next.js and the app router is, that the router events got removed: vercel/next.js#41934
that problem is now, that the navigation hook is already triggered, even though the page is not loaded yet, leading to wrong or no triggered events from elbwalker. This is something that needs to be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant