Close the earlier lessons and build this from the brief. The data functions are
in lib/dashboard.js.
The brief
Dashboard (/):
- Hello, Ada as the heading, from
getProfile(), shown as soon as the profile is loaded. - Under it, 4-day streak · 240 minutes this week, from
getStreak()andgetMinutesThisWeek(). These are slow, so show Loading progress… until both are ready, without holding up the heading. - The two slow queries run at the same time.
History (/history):
- History as the heading, and a list such as Monday: Routing, from
getHistory(). - It takes over a second, so following History shows Loading history… immediately.
Acceptance checks: reload / and watch the heading appear before the progress
line, which arrives about a second later (not two). Follow History.
Runs with real Next.js on your computer: unzip, then
npm install and npm run dev. Hint 1: the progress line
An async Progress component that loads both values with Promise.all, inside
a <Suspense> in the page.
Hint 2: History
app/history/page.jsx and app/history/loading.jsx.
Show one solution
Runs with real Next.js on your computer: unzip, then
npm install and npm run dev. Check yourself
- When should two queries run one after the other instead of together?
- What's the difference between
loading.jsxand a<Suspense>in a page? - Why does an error page write its own message instead of showing
error.message?
Completion is saved in this browser only. It does not measure mastery.