Skip to content
← Back to activity

Public problem

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

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

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.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

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