Saved screens — the criteria you keep coming back to
By the end of this lesson you will have two named screens saved in this browser under a versioned key, each one a link that reruns its criteria, and proof that an address edited by hand meets the same allowlist as the form.
Retyping four filters every morning is how a tool stops getting used. This lesson makes a screen a thing you name and reopen.
What a saved screen is
A name and a set of filters. Nothing else — and specifically not the results:
type SavedScreen = {
name: string;
filters: Filter[];
sort: string;
createdAt: string;
};
Saving results would freeze a snapshot of yesterday and quietly show it to you tomorrow. Saving criteria means reopening asks the market again. The whole value of a screen is that its answer changes.
Where it lives, and the same three rules
Browser storage, exactly like your notes in Build Your First Tool, and for the same reasons: personal, changes often, no server needed. And the same three rules apply, which is a good sign that you learned something general:
- Version the key (
screens-v1), so a shape change does not break the tool for anyone who used the last one. - Guard the parse with
try/catch, because half a write from a crashed tab throws and takes the page down. - Key by name, not index, so reordering does not silently rename people's screens.
Noticing that these are the same three rules is the point. That is what "transferable" means in practice.
The URL is the other place a screen can live
Worth considering, and cheap: encode the current filters into the query string. Then a screen is shareable, bookmarkable, and survives you clearing storage — and the back button starts working the way people expect.
/screen?f=market_capitalization:gt:1000000000,dividend_yield:gt:0.02
It also creates one obligation. Anything in a URL is input from a stranger, because someone can send you a link. Everything from the filters lesson applies to it: validate against the allowlist, drop what does not pass, never trust the string.
Say when the results are from
A saved screen reopened tomorrow runs against tomorrow's data — good. But recall from your first screen that last_day_data_date was 2026-08-24 on a screen run on the 25th. A screen is always at least one session behind, and that must be visible next to the results rather than assumed.
This is the same discipline as the data-age panel in Build Your First Tool, applied to a different surface. It is also what makes the breadth wall in unit 4 an observation instead of a claim.
Try it now
Save two screens you would genuinely use, close the tab, reopen and run one.
The prompt
Mock mode on, plan mode on, and paste:
Add saved screens. A SavedScreen is { name, filters: Filter[], sort,
createdAt }: criteria only, never rows. Store the parsed filters, and
build each link back from them as f=field:op:value; there is no sort
control yet, so sort holds the page's default. Keep them in localStorage under screens-v1,
as an object keyed by name, and guard the parse so a broken value
gives an empty list instead of a blank page. Put the storage code in
src/lib/saved-screens.ts as functions that take and return strings,
so tests/saved-screens.test.ts can run without a browser; write those
tests first. Add a small client component that saves the current
screen under a name and lists the saved ones as links to the screen
page with their f= query. The server side does not change. No new
request. Done means npm test, typecheck, lint, check:leak green; show
me the diff.
A good answer adds src/lib/saved-screens.ts, its test file and src/components/SavedScreens.tsx, and touches the screen page only to show that component. Nothing on the server changes, because a saved screen is just a link back to the page.
Check it yourself
- Save two screens, close the tab, reopen: both are listed, and opening one reruns it — free in mock mode.
- In the browser's developer tools, under Local Storage,
screens-v1holds names and filters and no rows. - Set
screens-v1to{brokenby hand and reload: an empty list, not a blank page. - Save a second screen under an existing name: it replaces that one rather than adding a twin.
Break it on purpose
Take the URL of a screen, edit the filters in the address bar by hand to something absurd, and load it. What happens next tells you whether the allowlist from the filters lesson is real or whether you only validated the form.
Compare with ours
// src/lib/saved-screens.ts
export const KEY = "screens-v1"; // a new shape gets screens-v2
export function readScreens(raw: string | null): Record<string, SavedScreen> {
try {
const parsed: unknown = JSON.parse(raw ?? "{}");
return isScreenMap(parsed) ? parsed : {};
} catch {
return {}; // half a write from a crashed tab
}
}
The full state at the end of this unit is on the starter's branch ref/build-a-screener/u2.

Checkpoint
npm test && npm run typecheck
git status # only the files this step touched, no .env*
git add -A
git commit -m "Saved screens: criteria under screens-v1, keyed by name, parse guarded"
Then answer this lesson's questions.