/ blog/server-components-vs-client-components
blog / server-components-vs-client-components / overview.md

Server Components vs Client Components in 60 Seconds

Still confused by the Next.js App Router? Here is the mental model you need.

Don't overcomplicate it.

Server Components (The Default)

  • Run only on the server.
  • Have direct access to the database (e.g. await db.query()).
  • Cannot use useState, useEffect, or onClick.
  • Output raw HTML. Zero JavaScript is sent to the browser for them.

Client Components ("use client")

  • Render on the server and hydrate on the client.
  • Can use state, effects, and event listeners.
  • Their code is bundled and sent to the browser.

The Golden Rule: Keep your Server Components at the top of your tree to fetch data, and pass that data down to small, leaf-node Client Components for interactivity.

Tags

nextjsreact
0
0