جلب البيانات بالتوازي والتتابع والبث
حسّن تحميل البيانات في App Router عبر الجلب بالتوازي، وفهم الحالات التي تتطلب الجلب بالتتابع، والبث باستخدام Suspense.
جلب البيانات بالتوازي والتتابع والبث درس مجاني في Next.js 15 Fullstack (App Router + Server Actions) على CoddyKit. هذا هو الدرس 3 من أصل 3. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Next.js 15 Fullstack (App Router + Server Actions)، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Next.js 15 Fullstack (App Router + Server Actions) 3 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Two Fetching Shapes
Server Components can fetch data sequentially (one waits for another) or in parallel (all at once). Choosing well dramatically affects load time.
Sequential Fetching
Sometimes one request depends on another result, forcing order. This creates a waterfall and is slower.
const user = await getUser(id);
const posts = await getPosts(user.teamId); // needs user firstParallel Fetching
Independent requests should start together. Initiate the promises, then await them with Promise.all.
const userP = getUser(id);
const postsP = getPosts(id);
const [user, posts] = await Promise.all([userP, postsP]);Avoiding Waterfalls
An accidental waterfall happens when you await each fetch on its own line even though they are independent. Kick them off before awaiting.
Streaming with Suspense
You do not have to wait for everything. Wrap slow parts in Suspense so fast content streams to the user immediately.
import { Suspense } from "react";
<Suspense fallback={<Spinner />}>
<SlowComponent />
</Suspense>loading.tsx is Suspense
The special loading.tsx file is automatically a Suspense boundary for the whole route segment, giving an instant loading state.
Granular Streaming
Place multiple Suspense boundaries so each section reveals as soon as its own data is ready, instead of blocking on the slowest one.
Fetching at the Leaf
In RSC you can fetch data exactly where it is needed (in the component that uses it). React dedupes identical requests, so colocated fetches are fine.
Request Memoization
Next.js memoizes fetch calls with the same URL/options within a single render pass, so calling it in multiple components does not hit the network twice.
Preloading Data
You can start a fetch early (a preload function called before render) to overlap network time with rendering of other parts.
export function preload(id) { void getUser(id); }Picking a Strategy
Default to parallel + colocated fetching; add Suspense boundaries around slow, independent sections; only go sequential when a real data dependency exists.
Quick Check
How do you avoid a data fetching waterfall for two independent requests?
Recap
You learned to fetch in parallel with Promise.all, avoid accidental waterfalls, and use Suspense (including loading.tsx) to stream UI progressively. Next.js memoizes fetches, so colocated leaf fetching is efficient.
الأسئلة الشائعة
هل درس «جلب البيانات بالتوازي والتتابع والبث» مجاني؟
نعم — نص درس «جلب البيانات بالتوازي والتتابع والبث» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Next.js 15 Fullstack (App Router + Server Actions)، انتقل إلى CoddyKit PRO. تتضمن دورة Next.js 15 Fullstack (App Router + Server Actions) 3 دروس في المجموع.
ماذا ستتعلم في «جلب البيانات بالتوازي والتتابع والبث»؟
حسّن تحميل البيانات في App Router عبر الجلب بالتوازي، وفهم الحالات التي تتطلب الجلب بالتتابع، والبث باستخدام Suspense. تتمرن على Next.js 15 Fullstack (App Router + Server Actions) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Next.js 15 Fullstack (App Router + Server Actions)؟
لا تُشترط خبرة سابقة. Next.js 15 Fullstack (App Router + Server Actions) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 3.
كم من الوقت يستغرق درس «جلب البيانات بالتوازي والتتابع والبث»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Next.js 15 Fullstack (App Router + Server Actions) هذا؟
نعم. كل درس في Next.js 15 Fullstack (App Router + Server Actions) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- جلب البيانات من جانب الخادم
- التخزين المؤقت وإعادة التحقق
- جلب البيانات بالتوازي والتتابع والبث