react-chartjs-2 in Next.js: typed Bar and Line charts in the App Router

react-chartjs-2 is the React wrapper for Chart.js, and in the Next.js App Router it needs three things: a "use client" file, ChartJS.register with the parts your chart uses, and a wrapper div with a height. This page builds a typed Bar and Line chart with react-chartjs-2 5.3.1 and Chart.js 4.6.1, reads dark theme colours from CSS variables, feeds the data from a Server Component and adds a label and a fallback table for screen readers. It also says when our animated Analytics Dashboard V1 fits better and when Chart.js is the right tool.

Analytics Dashboard V1, preview

By buying you agree to the Terms.

Ready forCursorv0Lovableshadcn CLI

Full product pageReact · Tailwind · TypeScript