customerio-node TypeError: url_1.URL is not a constructor in Next.js

In a Next.js 14 project, calling getCustomersByEmail(email) on the APIClient from customerio-node throws Unhandled Runtime Error. TypeError: url_1.URL is not a constructor. The same call works in a plain Node server. The client was instantiated in app-router code that ends up executing in the browser.

customerio-node is a server-side library only: it relies on Node's URL global, which does not exist in the browser runtime, so importing or executing it client-side throws url_1.URL is not a constructor. Fix: keep the APIClient on the server (route handlers / server actions) and never bundle it into client components. For browser-side tracking, use Customer.io's JavaScript source snippet instead of this library. Source: https://github.com/customerio/customerio-node/issues/156