Documentation
@chartts/reactRemix
Use Chart.ts with Remix. Load data in loaders, render charts in routes. SVG output works with streaming and nested routes.
Installation
npm install @chartts/react
Basic usage with loaders
import { json } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
import { BarChart } from '@chartts/react'
export async function loader() {
const metrics = await db.getMetrics()
return json({ metrics })
}
export default function Dashboard() {
const { metrics } = useLoaderData<typeof loader>()
return <BarChart data={metrics} x="month" y="sales" className="h-64" />
}Streaming with defer
Use Remix's defer for slow data sources. Chart.ts components work with Suspense boundaries - render a skeleton while data loads, then swap in the chart.
import { defer } from '@remix-run/node'
import { Await, useLoaderData } from '@remix-run/react'
import { Suspense } from 'react'
import { LineChart } from '@chartts/react'
export async function loader() {
return defer({ metrics: db.getMetrics() })
}
export default function Dashboard() {
const { metrics } = useLoaderData<typeof loader>()
return (
<Suspense fallback={<div className="h-64 animate-pulse card" />}>
<Await resolve={metrics}>
{(data) => <LineChart data={data} x="month" y="revenue" />}
</Await>
</Suspense>
)
}Nested routes
Chart.ts components work in any Remix route, including nested layouts. Share chart configuration through route context or layout components.
Actions and mutations
Update chart data through Remix actions. The chart re-renders automatically when loader data changes after a form submission or action redirect.