Server for Heavy Dependencies
You'll learn: How to keep large, heavy libraries on the server instead of shipping them to the user's browser, dramatically reducing bundle size.
The Problem: Libraries Are Heavy
Some libraries are essential but huge. A markdown parser might be 50KB. A date formatting library like moment.js is 300KB+. An advanced math or charting library can be even larger. In traditional React apps, if you import these libraries, they ship to the browser — every user downloads them, even if they only need the result of using that library.
The Server Components Solution
Server Components let you keep heavy dependencies on the server. You use the library to process data server-side, then pass only the lightweight result to the client.
Analogy: Instead of shipping a customer a whole factory to make a widget, you manufacture the widget at your factory and ship only the finished product.
Example Pattern
// ServerComponent.tsx (no 'use client')
import { marked } from 'marked'; // 50KB library
async function BlogPost() {
const markdown = await fetchMarkdown();
const html = marked(markdown); // Process on server
return <article dangerouslySetInnerHTML={{ __html: html }} />;
}
The marked library never reaches the browser. Users get only the processed HTML. Your bundle size stays small, your page loads faster.
When to Do This
- Markdown or syntax highlighting processors
- Heavy date/time utilities (use
date-fnson server, pass formatted strings) - Complex data transformations
- PDF generation, image processing
- Any library you only need for processing, not interaction
Key Takeaway: Server Components let you use heavy libraries without penalizing users — process on the server, ship only the result to the browser.