React Core & Hooks (407 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)
What are React Server components?
junior LevelMost AskedCode ExampleComponentsFormsPerformance
React Server Component is a way to write React component that gets rendered in the server-side with the purpose of improving React app performance. These components allow us to load components from the backend.
Note: React Server Components is still under development and not recommended for production yet.
Practical Code Example
jsx
// React Server Components (RSC): Execute ONLY on the server, sending zero JS bundle to the client
import db from '@/lib/db';
export default async function UserListPage() {
const users = await db.user.findMany(); // Direct server database access
return (
<ul>
{users.map((u) => (
<li key={u.id}>{u.name} ({u.email})</li>
))}
</ul>
);
}