Back Navigation
Back returns to where you came from, but skips pages at the same level as this one or lower. Settings is lower than every other page.
Every Back button of the app follows this one rule: the Back in the top bar, and the Back of the household sidebar on desktop. The few Backs that do something else are listed at the end of this page.
Page levels
Every page has a level. Level 1 is the top. A smaller number is a higher page.
| Level | Pages | Example |
|---|---|---|
| 1 | Pantry, Shopping, Cooking | Pantry |
| 2 | a vendor’s cart | the Costco cart |
| 3 | an item page, any tab | Milk, Tags tab |
| 4 | the settings menu (mobile only; it has no Back of its own) | Settings |
| 5 | a settings section page: General, Members, Activity, and the Locations, Tags, Vendors, Recipes and Shelves lists | Settings › Tags |
| 6 | one location, tag, vendor, recipe or shelf, any tab | the tag “Dairy”, Items tab |
Settings is lower than every other page, because entering settings feels like going deep into how the household is set up. Inside settings, the menu is above the lists, and the lists are above one row.
Sign-in, sign-up, joining a household and onboarding have no level. They are never a Back target.
The rule
When the user presses Back:
- All tabs of one thing are one page. All tabs of one item, or of one tag, vendor, recipe, shelf or location, count as one page. So Back never stops on another tab of the same thing.
- Look at the page the user came from: the opener. If the opener is higher than this page, go there. If it is lower, go there too. “Lower” is the exception: an item opened from a tag’s Items tab returns to that tag.
- If the opener is at the same level, skip it. For example: the Tags list, then the Vendors list. Back from the Vendors list does not go to the Tags list.
- Keep going back. Skip every page at the same level or lower. Stop at the first higher page.
- Nothing found: go to the page’s fixed fallback.
| Back from | Fallback |
|---|---|
| an item page | Pantry |
| one tag, vendor, recipe or shelf | its list (for example Settings › Tags) |
| one location | Settings › Locations |
| a settings section page, on mobile | the settings menu |
| the household sidebar (desktop) | Pantry |
| a vendor’s cart | Shopping, sorted by most recent |
Pantry, Shopping and Cooking are at the top, so they have no Back. The settings menu has no Back either: on a phone it is one of the four bottom bar tabs, so the bottom bar is the way out.
Unsaved changes. On an item page or a settings row with unsaved changes, Back first opens the Unsaved changes dialog. The user saves or discards. Only then does Back go anywhere. The same happens after a Save or a Delete that leaves the page: the app then goes Back by this rule.
Back forgets the way it came
After Back, the app forgets every page after the target. So the next Back cannot return to the page the user just left. Without this, the user could go round in a circle: item → settings → item → settings.
The browser’s own Back button, and the phone’s Back gesture or button, work the same way. They also make the app forget the pages after the one they land on.
Example:
- Pantry → Milk → Manage tags → Settings › Tags.
- The user presses the phone’s Back. They are on Milk again.
- The user presses the app’s Back on Milk. They go to Pantry, not to the Tags list.
When Back finds no target and goes to the fallback, the app forgets the whole way. The fallback page starts a new history.
One case the rule does not fix (accepted by the owner). Pantry → Milk → Settings › Tags, then the app’s Back (to Milk), then the browser’s Back. The browser shows the Tags list again. The app’s Back there now goes to Pantry, not to Milk. For the browser, Milk is “forward” at that point, and the app has already forgotten it.
Examples
| The way the user took | Back from the last page goes to |
|---|---|
| Pantry → Milk, Tags tab → Manage tags → Settings › Tags | Milk, Tags tab. Then Pantry |
| Pantry → Milk → Manage tags → Settings › Tags → the tag “Dairy” | Settings › Tags. Then Milk. Then Pantry |
| a cart → Milk | the cart (it is higher than the item) |
| Pantry → Milk → Manage tags → Settings › Tags → Settings › Vendors (desktop sidebar) | Milk. The Tags list is at the same level, so it is skipped |
| Shopping → the settings menu (mobile) → Settings › Tags | the settings menu. It has no Back: the user leaves it with the bottom bar |
| Pantry → Settings › Tags → the tag “Dairy” → its Items tab → Milk | the tag “Dairy” (the opener is lower: the exception). Then the Tags list. Then Pantry |
| a link opened straight into the tag “Dairy”, no way before it | Settings › Tags (the fallback) |
| Pantry → Settings › General → Settings › Locations → the location “Home” | Settings › Locations. Then Pantry: General is at the same level as the list, so it is skipped |
| Shopping sorted by name → the Costco cart | Shopping, still sorted by name |
| a link opened straight into a cart | Shopping, sorted by most recent (the fallback) |
| desktop: Settings › Tags → the tag “Dairy” → Settings › Vendors (sidebar) | the tag “Dairy”. It is the opener and it is lower, so the exception applies. Kept on purpose for now; we will look at it again after user feedback |
Mobile and desktop
The rule is the same on both. Only the place of the Back button differs.
| Page | Mobile | Desktop |
|---|---|---|
| an item page, or one location, tag, vendor, recipe or shelf | the Back in the top bar | the Back in the top bar |
| a settings section page (General, Members, Activity, a list) | the Back in its own top bar | the Back at the top of the household sidebar. The page has no Back of its own |
| the settings menu | no Back: it is a bottom bar tab page | (no menu page: Settings opens General directly) |
| a vendor’s cart | the Back in the top bar | the Back in the top bar |
On desktop the household sidebar links one list to another. So on desktop the user can move from list to list, and Back skips those lists (rule step 3).
A page with a Back button has no bottom bar on a phone
On a phone, a page with a Back button in its top bar has no bottom navigation bar. The Back button is the way out, and the list gets the whole screen height. On desktop the sidebar follows its own rule, which does not change.
The four bottom bar tab pages show the bottom bar and have no Back button on a phone: Pantry (/), Shopping (/shopping), Cooking (/cooking) and the settings menu (/settings). The bottom bar shows which tab is open.
| Page | Phone: bottom bar | Desktop: sidebar |
|---|---|---|
| Pantry, Shopping, Cooking, and the Pantry lists of shelves, vendors and recipes | shown | shown |
the settings menu (/settings) | shown, with the Settings tab active | (no menu page: Settings opens General) |
| a vendor’s cart | hidden | shown |
| a shelf, vendor or recipe view in Pantry (its Go back opens the Pantry list) | hidden | shown |
| an item page | hidden | hidden |
| every settings section page | hidden | shown (the household sidebar) |
| one location, tag, vendor, recipe or shelf | hidden | hidden |
The views in Pantry count too, though their Go back does not follow the Back rule above: what matters is the Back button in the top bar.
When you add a page with a Back button in its top bar, add it to isFullscreenPage in apps/web/src/lib/layoutRules.ts. That one function decides when the bottom bar and the sidebar are hidden. A full-screen page must have its own <h1>: the layout adds its hidden app-name heading only on pages with the bottom bar. The settings menu is the one page with the bottom bar AND its own visible <h1> (its title); the layout adds no hidden heading there (isSettingsRootPage).
Backs that do not follow this rule
These buttons go “back” in some way, but they do not leave the page by the rule. Each one has a reason.
| Button | What it does | Why it stays |
|---|---|---|
| Go back in the pantry’s recipe, shelf and vendor views | returns to the pantry’s list of recipes, shelves or vendors | it is a view inside Pantry. The page stays Pantry |
| Back in the onboarding steps | shows the previous step | the steps are inside one page |
| Back in the user panel of the sidebar | closes the panel and shows the main sidebar | it does not go to another page |
| Back to the household on the Activity page, when the user may not see the activity | opens Settings › General | a fixed link on an error screen. General is at the same level, so the rule would skip it |
| Nevermind in the confirm dialogs of Cooking and of a cart | closes the dialog | it does not go to another page |
When you design a new page
- Pick its level from the table above. Most new pages fit one of the six levels.
- Pick its fallback: where Back goes when the user opened the page from a link, with no way before it.
- Check the examples with the new page in them. Does Back land where a user expects?
- A new level, or a page that should break the rule, is a design decision. Bring it to the owner first.