Skip to content

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

@JannikZed

Description

@JannikZed

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions