How autosave is built
Until now, reloading /build gave you an empty editor. The PDF and the JSON export were the only copies you could keep. Now the editor saves your resume in this browser and restores it when you come back. Nothing is uploaded, and there is still no account.
This post covers how that works: what is stored, when a save happens, how the load avoids overwriting your work, what happens to a save the app cannot read, what Start over does, and what autosave does not do.
What you will notice
- Fill in a section, press its Save, reload the page. The resume is back, and your name shows on the contact card.
- A successful save shows nothing. There is no "Saved" label.
- If the browser refuses to store the resume, you get one warning: "Could not autosave this resume in this browser. You can keep editing."
- Start over is a new button on the app bar. It asks first, then empties the editor and deletes the saved copy.
Export JSON, preview and the PDF work as before.
Where the pieces live
| Piece | Path | Role |
|---|---|---|
| Storage format | src/lib/document/persistence.ts |
loadAutosave, saveAutosave, clearAutosave and the two storage keys. Plain TypeScript, no React. |
| Hook | src/components/document/useAutosave.ts |
Load on mount, debounced save, flush on hide, clear for Start over. |
| Provider | src/components/document/ResumeDocumentProvider.tsx |
Calls useAutosave and exposes it through useResumeAutosave. |
| Schema | src/types/schemas.ts |
New editorFormValuesSchema, used to check a save before it is loaded. |
| UI | src/components/forms/StartOverDialog.tsx, Notices.tsx, hooks/useStartOver.ts, hooks/useAutosaveWarning.ts |
The confirm dialog and the warning snackbar. |
The persistence functions take a small storage interface (getItem, setItem, removeItem) instead of reaching for window.localStorage directly. The hook passes the real localStorage in.
What is stored
One key in localStorage, resumer-document. Shortened, it looks like this:
{
"format": "resumer-autosave",
"schemaVersion": 1,
"savedAt": "2026-10-20T20:41:41.000Z",
"values": { "personalDetails": { ... }, "contactDetails": { ... }, "experienceItems": [ ... ], "educationItems": [ ... ], "personalProjects": [ ... ] }
}
values is the editor document as the reducer holds it, in camelCase. The React keys the reducer keeps for the experience and education lists are not stored. On load, replaceDocument creates new ones, the same way it does after a LinkedIn import.
This is a different file from the JSON export. The export is a snake_case resumer-workspace file you download. The autosave is an internal format that only this browser reads.
The editor document did not have a Zod schema before, only a TypeScript interface in src/lib/resume.ts. That interface is gone. The type is now inferred from a schema built out of the existing pieces:
// src/types/schemas.ts
export const editorFormValuesSchema = z.object({
personalDetails: personalDetailsSchema,
contactDetails: contactDetailsSchema,
experienceItems: z.array(experienceItemSchema),
educationItems: z.array(educationItemSchema),
personalProjects: z.array(descriptiveSectionSchema),
});
The save wraps it in an envelope, and the load checks the whole thing:
// src/lib/document/persistence.ts
const autosaveEnvelopeSchema = z.object({
format: z.literal("resumer-autosave"),
schemaVersion: z.literal(1),
savedAt: z.iso.datetime(),
values: editorFormValuesSchema,
});
When a save happens
The hook watches the document in the store. When it changes, a timer starts. After 500 ms without another change, the hook writes.
// src/components/document/useAutosave.ts
const AUTOSAVE_DEBOUNCE_MS = 500;
The hook also writes right away when the tab is hidden (visibilitychange to hidden) or the page is going away (pagehide). Switching tabs, closing the tab or reloading all flush a pending save. There is no beforeunload handler, so the page never asks "Leave site?".
There is one thing to know about "when the document changes". The contact, experience and education forms keep their own local state while you type, and only write to the store when you press the section's Save. Autosave follows the store. So the trigger is pressing Save, not each keystroke. Text in an open form that you have not saved yet is not autosaved, and a tab switch does not save it either.
Two checks keep it from writing when it should not:
- Nothing is written before the load has finished. A
hydratedref stays false until then. - The hook keeps the last saved JSON string as a baseline. If the current document serializes to the same string, it skips the write.
Both are there for the same reason. The first render of /build is an empty document. Without these checks, that empty render could be written over a saved resume before the load put it back.
Loading, and the LinkedIn return
The load runs in a layout effect, once per mount:
// src/components/document/useAutosave.ts
useClientLayoutEffect(() => {
if (!didLoad.current) {
didLoad.current = true;
const storage = browserStorage();
if (storage) {
const result = loadAutosave(storage);
if (result.ok) {
baselineRef.current = serializeValues(result.values);
dispatch(replaceDocument(result.values));
setStatus("saved");
} else {
baselineRef.current = serializeValues(valuesRef.current);
}
} else {
baselineRef.current = serializeValues(valuesRef.current);
}
}
hydrated.current = true;
// cleanup cancels the timer and turns writes off
}, [cancelTimer, dispatch]);
It is a layout effect on purpose. When you come back from LinkedIn sign-in, LinkedInImport restores the editor snapshot it kept in sessionStorage, and it does that in a normal (passive) effect. Layout effects run first, so the autosave load happens, then the LinkedIn snapshot replaces it. Coming back from LinkedIn gives you the document you left with.
The didLoad ref is for development. React Strict Mode runs layout effects again after the passive effects. A second load at that point would overwrite the LinkedIn restore, so the hook loads only once per mount.
useClientLayoutEffect is useEffect on the server and useLayoutEffect in the browser. That keeps the hook order the same in both and avoids the server warning about layout effects.
A save the app cannot read
If the stored string is not JSON, or does not match the envelope (wrong format, a schema version other than 1, missing fields), loadAutosave does three things:
- Copies the raw string, unchanged, to
resumer-document.bad. - Leaves the original key alone.
- Returns
{ ok: false, reason: "invalid" }, and the editor opens empty.
// src/lib/document/persistence.ts
function quarantine(storage: AutosaveStorage, raw: string) {
try {
storage.setItem(AUTOSAVE_BAD_STORAGE_KEY, raw);
} catch {
// Quota or blocked storage. The original key is left in place either way.
}
}
The page does not break, and the broken data is not deleted. The baseline is set to the empty editor, so the empty first render does not overwrite it either. The original key is replaced once you save something new. The copy in resumer-document.bad stays.
To be clear about what this is not: there is no restore button. Getting that data back means opening the browser's developer tools and copying it out by hand. The .bad key is a safety copy, not a recovery feature.
A save that fails
saveAutosave wraps setItem in a try. If storage is blocked or full, it returns { ok: false } and the hook sets its status to error. If the browser does not give the page a localStorage at all, the hook sets the same status.
useAutosaveWarning turns that status into one snackbar. It does not show the warning again while the status stays error. If a later save works and a later one fails, it shows again. You can keep editing in both cases. The document is still in memory, and preview, PDF and Export JSON still work.
Start over
Start over opens a dialog: "Start over? This clears the resume stored in this browser." Cancel closes it. Confirm calls clear:
// src/components/document/useAutosave.ts
const clear = useCallback(() => {
cancelTimer();
const empty = createEmptyFormValues();
const storage = browserStorage();
if (storage) clearAutosave(storage);
baselineRef.current = serializeValues(empty);
valuesRef.current = empty;
dispatch(replaceDocument(empty));
setStatus("idle");
}, [cancelTimer, dispatch]);
It cancels a pending save, removes resumer-document and resumer-document.bad, and replaces the editor with an empty document. It sets the values ref to the empty document straight away, so a flush in the same turn cannot write the old resume back. There is no undo. If you want a copy first, use Export JSON. Start over clears both the saved document and the quarantined .bad copy.
A small fix on the contact card
The contact card used to open its form when the name was empty, and only check that once. With autosave, the first render is always empty and the restored name arrives one step later, so the card stayed stuck in the form. It now follows the store. No name means the form is open. A name means the card shows. Pressing Edit still opens the form.
Form.tsx got smaller
Adding Start over and a second snackbar to Form.tsx would have made a long file longer. The preview dialog, the Start over dialog and the snackbars moved into their own components, and the export, Start over, warning and LinkedIn handlers moved into hooks under src/components/forms/hooks/. The behaviour of export, preview and PDF is the same.
What autosave does not do
- One browser, one device. There is no sync. Another browser, another device or a private window starts empty.
- It is not a backup. Clearing site data for Resumer deletes the save. Export JSON is the copy you keep.
- Private modes. Some block or limit storage. Then you see the warning once and nothing is saved.
- Two tabs. They do not know about each other. Each writes its own document, and the last write wins. There is no merge.
- Unsaved form edits. Only what you have saved in a section is autosaved.
- One document. There are no variants and no import of a JSON file yet.
- No migrations. A save with any
schemaVersionother than 1 is treated as unreadable and set aside. A future format change will need its own migration.
There is also no automated test suite in the repo yet. The checks for this change are manual steps: save and reload, Start over with cancel and confirm, a non-JSON string in the key, and a LinkedIn return with the import flag on.
You can try it in the editor at https://resumer.orlinivanov.com/build. Save a section, reload, and your resume is still there.