Constructing ERP Visualizations
By isolating heavy chart libraries in client-side components while pre-fetching data arrays in Server Components, Next.js applications maintain rapid initial rendering speeds. Dashboards no longer show blank white screens with loading spinners for 5 seconds.
The Composition Pattern
To maximize Server Component usage, we pass server-fetched data as props to client components. The server handles the heavy lifting (database queries, aggregation logic), and the client only receives a clean JSON array ready to be painted onto a bar chart.
// Server Component (page.tsx)
export default async function Page() {
const salesData = await getAggregatedSales(); // Heavy DB query
return <SalesChart data={salesData} />; // Passes to Client Component
}Optimizing Data Tables
Data grids with 10,000 rows will crash the browser DOM. We implement virtualized lists (using libraries like TanStack Virtual) and server-side pagination/filtering to ensure the DOM only ever renders the 20 rows currently visible on the screen.