#Difference between partial pre-rendering and using client components inside server components?
1 messages · Page 1 of 1 (latest)
Hi @dense oxide. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Partial pre-rendering and using client components inside server components are two different concepts in Next.js, each with its own use cases and benefits.
Partial Pre-rendering
Partial pre-rendering refers to the concept where only the route segments that change on navigation re-render on the client, and any shared segments are preserved. This is beneficial when navigating between two sibling routes, for example, /dashboard/settings and /dashboard/analytics. In this case, the settings and analytics pages will be rendered, and the shared dashboard layout will be preserved. This reduces the amount of data transferred and execution time, leading to improved performance [source (https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#4-partial-rendering)].
Using Client Components Inside Server Components
On the other hand, using client components inside server components is a composition pattern in Next.js. Client components allow you to write interactive UI that is prerendered on the server and can use client JavaScript to run in the browser. They can use state, effects, and event listeners, meaning they can provide immediate feedback to the user and update the UI. They also have access to browser APIs, like geolocation or localStorage [source (https://nextjs.org/docs/app/building-your-application/rendering/client-components)].
When interleaving client and server components, you can visualize your UI as a tree of components. Starting with the root layout, which is a server component, you can then render certain subtrees of components on the client by adding the "use client" directive. This allows you to keep some parts of your application interactive and client-side, while other parts are server-rendered for optimal performance [source (https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#interleaving-server-and-client-components)].