← Next.js Foundations
13 / 25
Lesson 13 — Data shaping
Shape the data before showing it
A Next.js page usually fetches data (from an API or database) and then prepares it: keep only what should be shown, sort it, pick the fields the page needs. With filter, sort and map this preparation is a short chain.
products.filter((p) => p.inStock).map((p) => p.name)
Note: the real Next.js router runs on a server and cannot run in this browser playground, so the exercise is a small plain-JS simulation of what Next.js does. The array below stands in for the fetched data.
Why it matters: clean, small data in means simple components out.
Want it another way?
Task
Keep published posts, sort them by date d (newest first), and return their titles.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.