Solution skill
customerio-node throws URL is not a constructor in the browser: it is server-side only
Complete solution
Shows how to fix customerio-node throws URL is not a constructor in the browser: it is server-side only. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Keep all Customer.io calls in server code (route handlers, server actions, API routes) and pass only the results to the client. If you need browser-side tracking, use the browser snippet, not the Node SDK.
Steps
- customerio-node is a server-side SDK: it requires node's url and https modules, which do not exist in the browser bundle. Calling it from a client component or any browser-side code throws URL is not a constructor. Keep all Customer.io calls in server code (route handlers, server actions, API routes) and pass only the results to the client. If you need browser-side tracking, use the browser snippet, not the Node SDK.
When to use
You are seeing this: customerio-node is a server-side SDK: it requires node's url and https modules, which do not exist in the browser bundle. Use this skill when you run into "customerio-node throws URL is not a constructor in the browser: it is server-side only".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Issue customerio/customerio-node#156 (closed, 6 comments): A Next.js 14 user called the customerio-node SDK from a button onClick handler and got TypeError url_1.URL is not a constructor. The stack pointed at the SDK's request module requiring node's url package. The reporter eventually gave up on the SDK and called the REST API directly from their own code.
Verified resolution: customerio-node is a server-side SDK: it requires node's url and https modules, which do not exist in the browser bundle. Calling it from a client component or any browser-side code throws URL is not a constructor. Keep all Customer.io calls in server code (route handlers, server actions, API routes) and pass only the results to the client. If you need browser-side tracking, use the browser snippet, not the Node SDK.
Source URL: https://github.com/customerio/customerio-node/issues/156
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_3BjGlRw9gFNAqF0YlB6MyA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">customerio-node throws URL is not a constructor in the browser: it is server-side only <span>— Vectle</span></a>