Repository navigation
Description
What
7 client components statically import recharts, so the library (heavy — it pulls in several d3-* packages) is eagerly bundled into the client JS of every dashboard route that uses a chart. Loading it via next/dynamic instead defers it until the chart actually renders, shrinking the initial JS for those routes and improving hydration / time-to-interactive.
Note on scope: the Next.js App Router code-splits per route, so
rechartsis not in the global app bundle — it only weighs down the dashboard routes that render charts (the marketing/auth pages are unaffected). The win is per-route, not app-wide.
Files that statically import recharts
web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsxweb/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.tsxweb/src/app/[locale]/(dashboard)/dashboard/prompts/_charts.tsxweb/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsxweb/src/app/[locale]/(dashboard)/dashboard/citations/page.tsxweb/src/app/[locale]/(dashboard)/dashboard/topics/[id]/page.tsxweb/src/components/agent/agent-chart.tsx
All are 'use client' components; none are currently lazy-loaded.
Suggested approach
Load each chart component through next/dynamic with ssr: false and a lightweight skeleton fallback. Charts are client-only visualizations behind auth, so disabling SSR costs nothing (no SEO/content impact) and keeps recharts out of the route's first paint.
For the dedicated chart files (*_charts.tsx, agent-chart.tsx), wrap them at the import site:
import dynamic from 'next/dynamic';
import { Skeleton } from '@/components/ui/skeleton';
const ReferralTrendChart = dynamic(
() => import('./_charts').then((m) => m.ReferralTrendChart),
{ ssr: false, loading: () => <Skeleton className="h-64 w-full" /> },
);For the three pages that import recharts directly (shopping, citations, topics/[id]), extract the chart JSX into a small child component first, then dynamic-import that child the same way.
Acceptance
- No route eagerly bundles
recharts; each chart loads vianext/dynamic(ssr: false) with a skeleton fallback - All existing charts still render and behave the same once loaded
- No hydration warnings introduced
- (Optional) Note the before/after route JS size from
next buildoutput in the PR
Notes
- UI/perf change only; no data or API changes.
Activity
BharadwajKanneveti commentedon Jun 17, 2026
Hi @gkhngyk can I work on this issue?
gkhngyk commentedon Jun 18, 2026
Assigned — thanks @BharadwajKanneveti! 🎉 Recharts is imported across a few dashboard pages (insights, traffic, the agent chart, and the newer Site Audit charts), so wrapping those chart components in
next/dynamicwithssr: falseshould trim the shared route JS nicely. Watch for layout shift — a sized placeholder/skeleton while the chart chunk loads keeps it smooth.