All chapters

Chapter 11 · Part 3: Make it yours

Build the public page

Goal
Build the page anyone can open: a short list of public restaurants with search and filters, that shows nothing a stranger shouldn't see. And set the look every later screen will use.
Time
About 60 minutes. Go at your own pace.
Before you start
Chapter 10 done, with your restaurants in the database. Some of them marked public.

This is the first page a stranger will see, and so it does two jobs. It shows the restaurants you decided to make public, with search and filters. And it sets the look that every later screen will share, so the whole app feels like one thing.

Most of this chapter is about what the page does not show. A public page that works is easy. A public page that works and doesn't leak is the point.

What anyone is allowed to see

You decided this in Chapters 6 and 8: the owner chooses what's public, and the public never sees reviews or photos. Now it becomes code.

The public page showsThe public page never shows
Restaurants the owner marked publicRestaurants that aren't public, even if a search matches their name
A name, an area, a kind of foodPhotos, reviews, ratings, or visits
The features: Patio, Playground, and Play areaThe date a place was last checked, or who added it
How many places matchAnyone's name or email, or the database's own record ids

1. Set the look first

Before any page, the app needs a design that every screen can reuse. If you leave this for later, each screen gets its own colors and its own button, and the app slowly turns into five different apps.

The design for The Kids' Table is a short file you save in your plan folder, like the others. It lists the colors and what each is for, the type sizes, the shapes, and a few rules, such as one red button per screen.

plan/design-system.md
# The Kids' Table: design system

One design for every screen. Every color, size, and shape below is a token or a rule, and every new screen follows them. Tokens live in `app/globals.css`, and nowhere else.

## Colors

| Token | Hex | Use |
|---|---|---|
| tomato | `#C8102E` | The one primary button per view. Star ratings. Error icons |
| teal | `#0F5257` | Links, selected chips, the secondary button, tag text |
| cream | `#FFF8EC` | The page background |
| card | `#FFFFFF` | Cards, inputs, tables |
| line | `#F0E3D2` | Card borders and dividers. Not for controls |
| ink | `#2A2220` | All text, including text on tinted fills |
| muted | `#7A6B63` | Secondary text. Only on cream or card, 14px or larger |
| tomato-soft | `#FBE3E1` | The glow. Error notice fill |
| teal-soft | `#DCEDEB` | The glow. Tags. Info and success notice fill |
| edge | `#8F8174` | The border of every control (inputs, selects, unselected chips). 3.58:1 on cream. The line color is only 1.20:1, too faint to mark a control |
| tomato-dark | `#A80D26` | Primary button on hover |
| teal-dark | `#0B3F43` | Link and secondary button on hover |
| sun-soft | `#FFF1C9` | Warning notice fill |
| sand | `#F4ECE0` | Skeleton and disabled fills. No text on it |

The orange, yellow, and green in the logo are for illustration only. They are not tokens, so no screen can use them for text.

**Text rules:** ink on cream, card, and every tint. Muted only on cream or card, and only at 14px or larger. Teal for links and for chip and tag text. Color is never the only cue: a selected chip has a check mark, a notice has an icon and words, a status has a word.

## Type

Hanken Grotesk, in three weights only: 500, 700, and 800.

| Role | Size and line, weight |
|---|---|
| Page heading | 30/36, 800 on a phone. 36/40 from 640px |
| Section heading | 22/28, 800 |
| Restaurant name | 18/24, 800 |
| Body | 16/24, 500 |
| Detail, caption | 14/20, 500 |
| Label, chip | 14/20, 700 |
| Tag | 13/16, 700. The smallest text in the app |
| Form controls | 16px, always. Smaller makes iPhone Safari zoom the page when you tap |

## Shape, space, and depth

- Corners: 14px for controls, buttons, and notices. 16px for cards and table wrappers. Fully round for chips and tags only.
- Spacing: 4, 8, 12, 16, 24, 32, 48. Page gutter 16px, then 24px from 640px. Content no wider than 1040px.
- Cards sit in a grid of 1 column, then 2 from 640px, never more.
- Shadows: cards get a faint one. Only the one tomato button gets a tomato shadow.
- The glow: one per screen, behind the logo in the header only, clipped so it can't make the page scroll sideways.

## Interaction

- **Focus:** a 2px teal outline with a 2px offset, on everything you can interact with. An outline survives high-contrast mode. A shadow doesn't.
- **Targets:** every control at least 44px tall.
- **Motion:** a 120ms color change, and nothing at all for people who ask their device for less motion. Loading placeholders stay still.
- **Links:** teal and underlined. Hover darkens them.
- **Forms:** every control has a visible label. A filter form is a plain GET form with one button. It does not submit by itself when something changes.

## Pieces (`components/ui`)

Built once, used by every screen: `SiteHeader`, `TextField`, `Select`, `Chip` (a checkbox drawn as a pill, with a check when on), `TagPill`, `Button` (primary tomato, secondary white with a teal edge), `Card`, `Notice` (info, success, warning, error), `Skeleton`. Tables use one shared set of classes on a plain `<table>`.

Later chapters add pieces such as an avatar, a rating, and a photo tile, each when a screen first needs it.

**One tomato button per view.** Buttons in the rows of a list are secondary. A destructive action opens a confirm step, and that confirm button is the one tomato.

## Rules for every page

- A skip link comes first, then the header, then one `<main>`. One `h1` per page. Result cards are list items, with the name as an `h2`.
- Every list has four states: loading, empty, error, and not set up. "Nothing is public yet" and "nothing matches" are different messages.
- A public page shows generic errors only: "The list isn't available right now. Try again in a minute." Hints that name settings, databases, or addresses show only when running on your own computer.
- A public page never sends a database id (it contains the time the record was made), the date a place was last checked, who added it, or whether it's public.
- Pages that aren't for search engines, like the status and import pages, say so.

## Guardrails

1. The tokens in `app/globals.css` are the only source. The default palette is removed, so a stray `bg-zinc-200` draws nothing.
2. `tests/design.test.mjs` fails on any hex color or default-palette class outside `globals.css`, any font weight that isn't loaded, text under 13px, a round shape outside chips and tags, and any approved text and background pair that is too faint to read.
3. `plan/screen-checklist.md` lists eight things to check before any screen is done.
4. Every public page has a privacy check: with demo data, the page's HTML contains none of the private places, none of the people, none of the internal field names, and no database id.

One change from the design sheet, and why

The design sheet's soft border color is too faint to mark a search box. Accessibility rules ask for at least a 3 to 1 contrast between a form field's edge and the page behind it, and that color measures 1.2 to 1. A person with low vision may not see where the field is. So the app keeps the soft color for cards and adds a darker edge color for form fields. It's the same design, with one color added where one was needed.

The colors and sizes, which designers call tokens, live in one place, app/globals.css. The app also removes the built-in colors from Tailwind, the styling tool from Chapter 6, so a stray color class draws nothing at all. A test then fails loudly if one sneaks in. That's how the look stays consistent without anyone having to remember it.

2. Get a second opinion before you build

On the reference app, we had a second AI read the plan before writing any code. It found four problems that would have cost far more to fix later. The search form couldn't sit in the part of the page that's built ahead of time. A filter that submits by itself when you change it breaks an accessibility rule. The filter choices came from the settings file, which could one day leak a private place. And the status page, which is public, revealed the database's name.

You can do the same. It takes a minute, and it doesn't change any files.

Prompt for Claude Code
Audit the plan in plan/11-public-page.md and the design in plan/design-system.md before any code is written. Don't change any files. Read the app's current code too.

Tell me: what is inconsistent with the design system, what's missing for accessibility (contrast, focus, keyboard, labels, touch size), anything that could leak private data on a public page, and where the design will drift as more screens are added.

Give me a prioritized list of concrete fixes, with exact values. Push back if something is over-built.

Read what comes back, and decide what to adopt. You don't have to take every suggestion. Ask Claude to update the plan files with the ones you accept.

3. Ask Claude Code to build it

  1. Save the phase plan and the checklist

    Save these in your plan folder as 11-public-page.md and screen-checklist.md.

    plan/11-public-page.md
    # Phase 11: build the public page
    
    Read `plan/00-app-plan.md`, `plan/08-data-model.md`, `plan/10-bring-in-content.md`, `plan/design-system.md`, and `plan/screen-checklist.md` first. This phase builds the page anyone can open, and sets the look every later screen will use.
    
    ## Goal
    
    The home page lists the restaurants the owner marked public, with a search box and filters, and no sign-in. It has the app's design, and it shows nothing a stranger shouldn't see.
    
    ## What to build
    
    - **The design first.** Put the tokens from `plan/design-system.md` into `app/globals.css`, with Tailwind's default palette removed. Load Hanken Grotesk. Light only. If there's a logo file in `public`, use it in the header exactly as it is.
    - **The pieces,** in `components/ui`: `SiteHeader`, `TextField`, `Select`, `Chip`, `TagPill`, `Button`, `Card`, `Notice`, and `Skeleton`. Build only these now.
    - **The filter logic,** in `lib/publicFilters.ts`, as plain functions with tests. The web address is typed by strangers, so every value is checked against the lists in the settings file, and anything else is thrown away. Only `q`, `area`, `food`, and `feature` mean anything. The filter always includes `public: true`, and no address value can change that. Search matches every word typed against the stored name key.
    - **The database query,** in `lib/restaurants.ts`. It returns only name, area, food type, and features. It never returns the database id, the public flag, the last-checked date, who added it, or photos. Choices in the filters come from the public places only.
    - **The home page.** The heading is built ahead of time. The search form and the results depend on the web address and the database, so they go inside `<Suspense>`. The form is a plain GET form using `next/form`, and its one button is the only way to submit. Chips are checkboxes. Features use "has every feature you pick".
    - **The states:** loading, "nothing is public yet", "nothing matches" (with a Clear filters link), and "the list isn't available right now".
    - **Restyle** the import page and the status page with the same pieces and tokens. In production, the status page says only "Connected" or "Not connected". Both pages tell search engines not to list them.
    - **Tests** for the design rules and for the filter functions.
    
    ## Rules for this phase
    
    - Show only places that are public. Show no photos, no reviews, no ratings, no visits, and no names of people.
    - Nothing submits by itself. Controls are labeled, at least 44px tall, with 16px text.
    - One tomato button on the screen.
    - Tell me what each command does before you run it.
    - Use the demo data. Don't use my real database.
    
    ## Done when
    
    - `npm test` passes, including the design tests.
    - With the demo data, the page shows the five public restaurants, and none of the three private ones.
    - Searching for a private restaurant's name finds nothing.
    - A filtered page's address can be shared and gives the same list.
    - On a production build, the page's HTML contains none of the private places, none of the people, and none of the words `lastChecked`, `createdBy`, `photos`, or `public`.
    - At 390px wide there's no sideways scroll, and the whole page works from the keyboard.
    - `npm run lint` and `npm run build` pass.
    
    ## Out of scope
    
    Sign-in, photos, reviews, and any change to the data. Those are later phases.
    
    plan/screen-checklist.md
    # Checklist for every new screen
    
    Go through this before a screen is called done. The tests in `tests/design.test.mjs` catch the first two. The rest are a person's job.
    
    1. **Only the app's own pieces.** The screen uses `components/ui` and the tokens in `app/globals.css`. No new colors, no default Tailwind palette, no new component that duplicates one.
    2. **One tomato button per view.** The main action is tomato. Every other button is secondary. A destructive action opens a confirm step, and that confirm button is the one tomato.
    3. **Four states.** Loading, empty, error, and not set up are all designed, not left blank. "Nothing here yet" and "nothing matches" are different messages.
    4. **Every control is labeled and big enough.** A visible label, a visible border, at least 44px tall, 16px text inside.
    5. **The keyboard works.** Tab through the whole screen. The order makes sense, the focus ring is always visible, and nothing needs a mouse.
    6. **A phone works.** At 390px wide there's no sideways scroll, and nothing is cut off.
    7. **A production screenshot.** Take any picture for the guide from a production build, so the developer badge isn't in it.
    8. **If the screen is public,** update the privacy check: the page's HTML contains none of the private places or people, none of the internal field names, and no database id.
    
  2. Add your logo, if you have one

    If you have a logo file, put it in the public folder. The header uses it exactly as it is. If you don't, ask Claude Code to use your app's name as text instead.

  3. Paste the prompt

    Stop your app first if it's running (click in its terminal and press Ctrl+C). This prompt makes Claude Code build the app for the privacy check, and building while the app runs can break a page that's open in your browser. Then keep Claude Code in the mode where you read each request. This is a big build, and it creates many files.

    Prompt for Claude Code
    Read plan/00-app-plan.md, plan/08-data-model.md, plan/10-bring-in-content.md, plan/design-system.md, plan/screen-checklist.md, and plan/11-public-page.md in this folder. Then do phase 11.
    
    Before you run any command, tell me in plain English what it does. Use the demo data, not my real database. When you finish, tell me how to open the page, and run the privacy check against a production build.

    What “demo data” means in the prompts

    It means sample data only, like the restaurants from Chapter 10. The line keeps Claude Code away from anything real you add later. Our screenshots come from a separate database in the same Atlas cluster, called kidstable_demo, so none of them show real people. The app uses whichever database MONGODB_DB names, and kidstable if that setting is missing. You don't need a demo database of your own yet. If Claude Code asks where the demo data is, point it at the sample restaurants you imported.

4. Try it

Start the app and open http://localhost:3000. You should see your public restaurants and none of the others.

PowerShell
npm run dev

What you should see

A header with your logo, a heading, a search box, filter chips, two drop-downs, one red button, and a list of cards. On a phone, the cards stack in one column. On a wide screen, there are two.

The Kids' Table public page on a phone: the logo, the heading Places to eat with kids, a search box, Patio, Playground, and Play area chips, Area and Food drop-downs, a red Show restaurants button, and the start of a list of five restaurants.
The public page on a phone, captured November 15, 2026.
The Kids' Table public page on a phone: the logo, the heading Places to eat with kids, a search box, Patio, Playground, and Play area chips, Area and Food drop-downs, a red Show restaurants button, and the start of a list of five restaurants.
The public page on a wide screen: the search form at a comfortable width, and five restaurant cards in two columns.
The same page on a wide screen.
The public page on a wide screen: the search form at a comfortable width, and five restaurant cards in two columns.

Now try it the way a visitor would:

  1. Tap Playground and pick an area, then press Show restaurants. The list narrows, and the address changes to something like /?feature=playground&area=katy. Copy that address, open it in another tab, and you get the same list.
  2. Notice that the chip you chose is teal with a check mark. The page never relies on color alone.
  3. Type part of a restaurant's name, like pony burg. Every word has to match.
  4. Type the name of a restaurant you made private. Nothing matches, even though it's in your database.
The page filtered to Patio in Katy: the Patio chip is teal with a check mark, Katy is chosen in the Area drop-down, and the list shows 3 restaurants with a Clear filters link.
Filtered, captured November 15, 2026. The chip shows a check mark, so color isn't the only clue.
The page filtered to Patio in Katy: the Patio chip is teal with a check mark, Katy is chosen in the Area drop-down, and the list shows 3 restaurants with a Clear filters link.
The page after searching for the word spotted, part of a private restaurant's name: 0 restaurants, a Clear filters link, and a message saying No restaurants match those choices.
Searching for a word from a private restaurant's name finds nothing.
The page after searching for the word spotted, part of a private restaurant's name: 0 restaurants, a Clear filters link, and a message saying No restaurants match those choices.

How it keeps private things private

There are three layers, and any one of them would catch a mistake in the others.

  1. The address can only ask for safe things

    Anyone can type anything into a web address. So the page treats every value as hostile. A value is kept only if it appears in your settings lists, and the rest is thrown away. Only four names in the address mean anything: q, area, food, and feature. The database filter always starts with public: true, and nothing in an address can change that. The tests try addresses like /?public=false and /?q[$ne]=x, and show that they do nothing.

  2. The database sends back only five fields

    Even for a place that is public, the page only receives five fields: its name, a simplified copy of the name that the search and sort use, its area, its food, and its features. A projection tells the database exactly which fields to send. The database id is left out on purpose, because it contains the moment the record was created. A test checks that the list of allowed fields and the projection stay in step.

  3. The choices come from public places only

    The drop-downs and chips offer only areas, foods, and features that some public place has. If they came from the settings file, a choice could exist because of a private place, and picking it would hint that it's there.

export function buildPublicFilter(filters) {
  const filter = { public: true };          // always. No address can change it.
  // ...every word typed must appear in the name key
  if (filters.area) filter.area = filters.area;
  if (filters.foodType) filter.foodType = filters.foodType;
  if (filters.features.length > 0) filter.features = { $all: filters.features };
  return filter;
}

Test it like a stranger would

The privacy check doesn't look at the page. It reads the raw web page your server sends, including the hidden data Next.js adds for the browser. With the demo data, it looks for the names of the private restaurants, the names and emails of the people, the internal field names, and the words “photo,” “review,” and “rating” in the visible text. On the reference app, 171 checks across eight addresses came back clean, on a production build and on the live site. Always run it on a production build. A development build behaves differently.

Why the filters live in the web address

The search form is an ordinary form that sends its choices in the address. That has three benefits. A filtered list is a link you can share. It works even before the page's scripts have loaded. And the filtering happens on the server, so the browser never receives places it isn't allowed to show. Hiding things with code in the browser doesn't protect them, because the data is already there to read.

The form also never submits by itself when you change a control. People using a keyboard or a screen reader can be thrown by a page that reloads when they touch a drop-down. The one red button is the only way to submit.

Why part of the page waits

This is the same reason as the status page in Chapter 9. The heading is built ahead of time, and the form and the list are built when someone asks, because they depend on the web address and the database. In Next.js 16, that part goes inside Suspense, which lets the heading appear instantly while the list loads.

Keeping the look consistent

Three things keep the design from drifting as you add screens:

  • A test for stray styles. It scans the code and fails on any color that isn't a token, any font weight the app doesn't load, and any text smaller than 13 pixels. A test that never fails proves nothing, so plant a bad color once on purpose and watch it get caught.
  • A contrast test. It measures every approved text and background pair, and fails if one is too faint to read.
  • The checklist you saved. Eight questions for every new screen, such as whether it works from the keyboard and whether it has no sideways scroll on a phone.

We also ran an automatic accessibility checker across five screens and walked the page with the Tab key. Both came back clean, once we made the import table reachable from the keyboard.

On the live site

When you save this to GitHub, Vercel publishes it. Open your live address. It shows the heading, then says “The list isn't available right now. Try again in a minute.” That's correct. The deployed app has no database address yet, and you'll add it in Chapter 16. Notice what the message doesn't say. A stranger doesn't learn which database you use, or that a setting is missing. The same goes for /status, which on the live site says only “Connected” or “Not connected.”

If it doesn't work

Next.js says “uncached data was accessed outside of Suspense.” Something that reads the web address or the database sits outside the Suspense wrapper. Move it inside.

The drop-downs are empty, or a message says no restaurants are public. None of your restaurants is marked public yet. Import the clean sample from Chapter 10, where five of the eight are.

The page zooms in when you tap a field on an iPhone. Text inside a form field must be 16 pixels or bigger. The design system says so, and the tests would catch a smaller size.

What Claude made

  • app/globals.css holds every color and size, in one place.
  • components/ui holds nine small pieces every screen will reuse: the header, a text field, a drop-down, a chip, a tag, a button, a card, a notice, and a loading placeholder.
  • lib/publicFilters.ts is the filter logic, with no database in it, so it can be tested alone.
  • lib/restaurants.ts has two new functions that return only public data.
  • app/page.tsx, PublicList.tsx, and PublicFilters.tsx are the page.
  • tests/design.test.mjs and tests/public-filters.test.mjs are the guardrails.
  • The import and status pages now use the same pieces, so the whole app matches.

Checkpoint

0 of 5

Next step: anyone can look, but only you can change anything. In Chapter 12, you'll add sign-in with an email and a password, and a waiting screen for new people until you approve them.

Last checked November 15, 2026. Software screens and free-plan limits change. If something here doesn't match what you see, the official link in the chapter is the source to trust.