Development

    Server Component

    A React component that renders exclusively on the server, sending only HTML to the client without any client-side JavaScript.

    Share

    Key Takeaways

    • Server Components send zero JavaScript to the browser, reducing bundle size by 30-50% for data-heavy pages.
    • They can directly access databases and APIs on the server without creating API endpoints or exposing secrets.
    • The 'use client' directive marks interactive components, creating a clear server/client boundary in your codebase.

    Server Components vs Client Components

    AspectServer ComponentClient Component
    JavaScript sentNone (HTML only)Full component code
    Can use useState/useEffectNoYes
    Can access database directlyYesNo (needs API)
    Can handle onClick/onChangeNoYes
    Rendering locationServer onlyServer (SSR) + Client (hydration)

    The key mental model: Server Components handle data, Client Components handle interactivity. A product page might use a Server Component to fetch product data from the database and a Client Component for the 'Add to Cart' button.

    Default to Server

    In Next.js App Router, components are Server Components by default. Only add 'use client' when you need browser APIs, event handlers, or React hooks (useState, useEffect). This naturally minimizes client-side JavaScript.

    Frequently Asked Questions

    Need Help With Implementation?

    Our team specializes in implementing the solutions described in this glossary.

    Get in Touch