TypeError when using the new Next.js App Router
stitot opened this issue · comments
The following serverside error is produced when using the new Next.js App Router:
TypeError: Cannot read properties of undefined (reading 'document')
Page renders fine using npm run dev
, even when error is produced, but due to the error the build is aborted when using npm run build
.
Note that error is NOT produced when using the old Pages Router, only on the new App Router.
My minimal code example:
"use client";
import React from "react";
import Highcharts from "highcharts";
import HighchartsExporting from "highcharts/modules/exporting";
import HighchartsReact from "highcharts-react-official";
if (typeof Highcharts === "object") {
HighchartsExporting(Highcharts);
}
export default function Chart() {
const options = {
title: {
text: "My chart",
},
series: [
{
data: [1, 2, 3],
},
],
};
return (
<>
<HighchartsReact
highcharts={Highcharts}
options={options}
/>
</>
);
}
Hi @stitot,
Thank you for contacting us!
This issue has been already reported and it is related to Highcharts, not the highcharts-react-official
wrapper.
Here: highcharts/highcharts#20129 you can track status of the report.
Best regards!