This is the course's final check: a different app, from a brief, with no
walkthrough. Plan first: list the routes, decide which parts are client
components, and which functions are server actions. Then build one working step
at a time. lib/recipes.js has everything you need from the "database".
Plan on 75 to 90 minutes in all, over two or three sittings; the 40 minutes
in the header is the first one. A sensible split:
The list with its tag filter, and the recipe page with its loading and
not-found files (about 40 minutes).
The titles and the form, with its validation and pending button (about 30).
Deleting, then the acceptance checks and the self-check below (about 15).
If you pause, write down what works and the next acceptance check to tackle.
Try those checks before opening the solution.
The brief
A Recipe Box.
Routes
Route
Shows
/
Recipes, links All, breakfast, dinner, baking that filter with ?tag=, and each recipe as a link with its minutes: Pancakes · 20 min
/recipes/[id]
The recipe's name, 20 minutes · breakfast, and a Delete recipe button
/new
Add a recipe: Name, Minutes and Tag fields, and Save recipe
Behaviour
A navigation bar on every page: Recipes and Add a recipe.
Page titles: Recipe Box on the list, Pancakes · Recipe Box on a recipe,
Add a recipe · Recipe Box on the form.
Opening a recipe shows Loading recipe… while it loads (it's slow on
purpose). An unknown id shows No such recipe with a link back.
The server checks the form: no name gives Enter a name., and minutes that
aren't a whole number of at least 1 give Enter the minutes as a whole
number., both announced with role="alert", keeping what was typed. While
saving, the button says Saving….
Saving opens the new recipe. Deleting goes back to the list.
Acceptance checks: filter by breakfast; open Pancakes; on the form,
type ten for minutes and save; then add Banana bread, 60 minutes,
baking, and delete it again.
Runs with real Next.js on your computer: unzip, then npm install and npm run dev.
Check your own work
Before opening the solution, go through this list. Each item names the day
that taught it, so you know where to look if one fails.
Only the form file starts with "use client". Every page loads its data
in a server component (Day 2).
/?tag=dinner filters on the server, and reloading keeps the filter;
/?tag=nope shows an empty list rather than an error (Day 3).
/recipes/999 shows No such recipe, not a crash (Day 3), and opening
a recipe shows Loading recipe… first (Day 4).
The checks are in the server action, not only in the browser: a
required or type="number" on an input doesn't count, because anyone can
remove it. After a failed save, what you typed stays in the fields (Day 5).
Saving… appears while saving, and the delete button belongs to one
recipe through bind (Day 5).
The three page titles match the brief (Day 6).
Any box you can't tick is the next thing to work on, not a failure.
Hint 1: a plan
Server: app/page.jsx, app/recipes/[id]/page.jsx with loading.jsx and
not-found.jsx, app/new/page.jsx, and app/actions.js. Client: only the form,
app/new/RecipeForm.jsx.
Hint 2: start from Study Notes
Its list, note page, form and actions have the same shapes. Copy the structure,
not the code, and rename as you go.
Runs with real Next.js on your computer: unzip, then npm install and npm run dev.
Your structure can differ. What matters is that data is read in server
components, changed only through server actions that check their input, and that
the acceptance checks pass.
What next
You can now build a Next.js app: pages and layouts from folders, server
components that load data, client components for interaction, forms that save
with server actions, and an API. From here:
Run the Recipe Box for real: download it and use npm run dev and
npm run build, as in the second lesson.
Add a database. Replace the in-memory list with a real one. The Next.js
docs at nextjs.org/docs show several options.
Deploy it, for example to Vercel from a GitHub repository.
If you haven't yet, React Intermediate in 7 Days goes deeper into the
React that every client component uses: reducers, context, custom hooks and
testing.
Completion is saved in this browser only. It does not measure mastery.