sodcalculator

10 Tech How-To

Build a Reading Tracker App That Saves Your Place

Guide 10-39484 · Updated · Step by step

A reading tracker app can record what you are reading, how far you have got, and the exact page or chapter where you stopped. This beginner-friendly plan uses a small web app with a book list and browser storage, so your progress remains after you close or reload the page on the same device.

What You’ll Need

  • A computer with a modern web browser and a code editor.
  • Basic familiarity with HTML, CSS, and JavaScript. You can still follow along if you are learning; build and test one step at a time.
  • A project folder for three files: index.html, style.css, and app.js.

Step-by-Step

  1. Decide what to track. Start with a small data model: a unique ID, title, author, total pages, current page, and status. Use statuses such as “Want to read,” “Reading,” and “Finished.” Decide that the current page is a number from zero to the book’s total pages; zero means you have not started. This keeps validation and progress calculations straightforward.
  2. Create the page structure. In index.html, add a heading, a form for book details, and a section where saved books will appear. Give each input a visible label. Use a text input for title and author, and number inputs for total pages and current page. Add a submit button such as “Add book.” Include a live message area for success or validation feedback, and load app.js with a script tag near the end of the body.
  3. Style the form and book cards. In style.css, make the form easy to use on narrow screens: arrange fields in a single column on phones and allow a wider layout on larger screens. Give buttons clear text and sufficient contrast. Avoid relying on color alone to communicate a book’s status; display the status as words too.
  4. Choose where data will live. For a first version, use the browser’s localStorage. It stores text on the current browser and device without a server, which is convenient for a personal prototype. It is not automatically shared across devices, and clearing site data can erase it. Keep a clear function that reads and writes one JSON array under a key such as readingTrackerBooks.
  5. Load saved books when the app starts. In app.js, read the storage key and parse the JSON inside a try/catch. If no value exists, start with an empty array. If the stored value is malformed or inaccessible, show a helpful message and use an empty list rather than letting the whole page fail. Render the books after loading.
  6. Validate and add a book. Listen for the form’s submit event and prevent the browser’s default page refresh. Trim the title and author, then check that the title is not blank, total pages is a positive whole number, and current page is a whole number between zero and total pages. Create an ID, set the initial status, add the object to the array, save it, redraw the list, and reset the form. Report invalid entries beside the relevant field where possible.
  7. Render progress clearly. For each book, show its title, author, current page out of total pages, status, and a progress indicator. Calculate percentage as current page divided by total pages, multiplied by 100; a finished book should reach 100%. Clamp progress to the valid range after validating the page number. Give a progress bar an accessible label, such as “12 of 240 pages,” so it is understandable without relying on its visual fill.
  8. Add controls to update a place. Put an “Update page” control on each book card. When it is used, validate the new page against that book’s total, update the object, and save and render again. Consider separate “Mark finished” and “Remove” buttons. Ask for confirmation before deleting if accidental removal would be frustrating. Use event delegation on the list container, or attach listeners when rendering, and identify the target book by its ID.
  9. Test persistence and edge cases. Add a book, record a new page, reload the browser tab, and confirm both values remain. Test page zero, the final page, a blank title, a decimal page, and a page larger than the total. Also test a book with one page. Fix any mismatch between what the form accepts, what the display shows, and what is saved.
  10. Plan for a second device only if needed. Local storage is suitable when one person uses the same browser. To sync across devices or accounts, you need a backend service, database, and authentication, plus a plan for conflicts when two devices update the same book. Do not treat browser storage as a backup; add an export/import option or choose a properly managed cloud data store before relying on the tracker.

Common Mistakes

A common bug is saving a JavaScript array directly to storage. localStorage stores strings, so serialize with JSON.stringify() and parse with JSON.parse(). Another is forgetting to save after an update or deletion; centralize the save operation and call it after every change. Avoid using the book title as its ID, since two books can share a title and titles can be edited. Generate a separate stable ID instead.

Do not calculate progress before checking that the total is greater than zero; division by zero produces an unusable result. Also avoid inserting user-entered titles into the page as raw HTML. Create elements and set their textContent so punctuation or markup in a title is displayed as text, not interpreted as page content.

Tips

Keep the first version focused on adding books and updating pages. A search box, sorting by title or last-read date, notes, and reading goals can come later. Store a last-updated timestamp if you plan to sort by recent activity. Make the current page the central control: it is simple to understand and works even if the reader does not use a specific e-book format.

Provide an export button that downloads the book array as a JSON file, and test importing only files with the expected structure. Include a note near the app explaining that saved data is local to that browser. If you later add accounts or cloud sync, document how users can access and remove their data.

Troubleshooting

  • Books disappear after a reload: Check that the save function runs after adding or editing, that the storage key is identical when reading and writing, and that the app is not running in a private browsing session that clears data. Browser settings can also block or clear site storage.
  • The page shows an empty list or a parsing error: A stored value may not be valid JSON. Catch parsing errors, clear only the app’s own storage key if appropriate, and add a fresh test book. Do not clear all browser data unless you intend to remove other site data too.
  • Progress is wrong or exceeds 100%: Confirm that current page and total pages are numbers, not unconverted input strings, and reject values outside the allowed range. Check that the percentage calculation uses the current book’s total.
  • Buttons stop working after the list refreshes: If you replace the list’s HTML, listeners attached to old buttons disappear. Reattach listeners after rendering or use event delegation on a container that remains in the page.
  • The app works on one device but not another: That is expected with local storage. Use an export/import workflow for manual transfer, or implement a backend and sign-in flow for automatic syncing.

Frequently Asked Questions

Does localStorage save my reading progress permanently?
It usually survives reloads and browser restarts, but users or browser settings can clear it. Keep an export or backup option if the data matters.

Can I sync my tracker between my phone and computer?
Not with localStorage alone. Cross-device sync requires a shared backend or another sync service, usually with an account or a manual export/import process.

Should I store the current page or a percentage?
Store the page and total pages, then calculate the percentage for display. That preserves the reader’s exact place and makes the progress bar easy to recalculate.

How should I handle audiobooks or ebooks without page numbers?
Add a separate progress type, such as chapter number or position in minutes, and store its unit explicitly. Do not mix unlike units in one field.

Can a finished book still be edited?
Yes. Let readers change the page or status at any time. If the current page equals the total, you can suggest “Finished,” but make the status editable rather than forcing it.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →