Hydration
الترطيب (Hydration)
GLS-000086
Definition
The process where React takes server-rendered HTML and attaches JavaScript event listeners to make it interactive.
العملية التي يأخذ فيها React HTML المُصيَّر من الخادم ويُرفق مستمعي أحداث JavaScript لجعله تفاعليًا.
Why It Matters
Hydration errors are common bugs in Next.js apps — usually caused by using browser-only APIs (window, localStorage) during server rendering.
أخطاء الترطيب هي أخطاء شائعة في تطبيقات Next.js — عادةً ناجمة عن استخدام APIs خاصة بالمتصفح (window وlocalStorage) أثناء التصيير من الخادم.
Full Definition
Example Usage
“Reading localStorage in a Server Component causes a hydration mismatch. Fix: use 'use client' and read it inside useEffect.”
“قراءة localStorage في Server Component تسبب عدم تطابق ترطيب. الإصلاح: استخدم 'use client' واقرأها داخل useEffect.”
AI Builder Tips
Avoid these mistakes when using Hydration:
Accessing window or document in a Server Component
Rendering different content on server vs client based on Math.random() or Date.now()
Sign in to unlock guided AI explanations from AI Teacher.
Generate a Prompt
Copy this prompt and use it directly with any AI model — no setup needed.
Help me build a project using Hydration. Explain: 1. What is Hydration and why it matters 2. The core architecture and required tools 3. Step-by-step implementation plan 4. Common mistakes to avoid: Accessing window or document in a Server Component, Rendering different content on server vs client based on Math.random() or Date.now() 5. Best practices and production tips