mixpanel-node icon indicating copy to clipboard operation
mixpanel-node copied to clipboard

Is there anyway to get this to work in the Next.js edge environment?

Open jmcannon opened this issue 2 years ago • 8 comments

On init, it throws an error Error: The edge runtime does not support Node.js 'http' module.

jmcannon avatar Apr 26 '23 04:04 jmcannon

Judging by the restrictions listed here: https://nextjs.org/docs/api-reference/edge-runtime#unsupported-apis it would probably take a ton of work to make this lib usable in that environment (no require statements, all deps in node_modules must use ES modules and not call any native Node.js APIs).

tdumitrescu avatar Apr 26 '23 16:04 tdumitrescu

Yes, I think you're right. I just fell back to the default Next serverless environment.

jmcannon avatar Apr 29 '23 04:04 jmcannon

Yes, I think you're right. I just feel back to the default Next serverless environment.

As an alternative, you can just call via mixpanel's HTTP API using fetch in the edge.

stephenasuncionDEV avatar May 03 '23 01:05 stephenasuncionDEV

looking for same. If it's too much work, would be easier for you guys to port mixpanel-js library for edge?

GorvGoyl avatar Nov 30 '23 03:11 GorvGoyl

would be easier for you guys to port mixpanel-js library for edge?

That seems like it would also be a big project, since the browser lib relies on a lot of browser APIs to function correctly.

tdumitrescu avatar Nov 30 '23 17:11 tdumitrescu