React & Modern Frontend (445 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)
What are React Server components?
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, zero client bundle footprint
import db from '@/lib/db';
export default async function ServerProfile({ userId }) {
const user = await db.user.findUnique({ where: { id: userId } }); // Direct DB query!
return <h1>{user.name}</h1>;
}