Skip to content
Tutorials

How to Build a Medicine Reminder App in JavaScript (Free PWA Source Code, 2026)

Build a medicine reminder app with HTML, CSS and JavaScript: daily dose schedule, taken-dose tracking, localStorage, notifications and PWA install β€” plus free downloadable source code from CodeFree.

CodeFree Team December 04, 2026 9 min read
How to Build a Medicine Reminder App in JavaScript (Free PWA Source Code, 2026)

Missing a dose is rarely about carelessness. In most Indian homes, one person is managing medicines for a parent with blood pressure, a spouse with thyroid tablets, and sometimes their own vitamin course β€” all at different times of the day. A simple medicine reminder app solves this quietly: add the medicine once, set the time, and the phone does the remembering. In this tutorial, you will build exactly that app with plain HTML, CSS and JavaScript, turn it into an installable PWA, and understand every line well enough to customise it for your own family or clients.

This is a perfect beginner-to-intermediate project because it uses real-world skills in a small package: forms, lists, localStorage, time handling, notifications and a service worker. No framework, no build tools and no backend are needed. If you get stuck at any step, you can also download the finished, working version free from CodeFree β€” the Mobile Medicine Reminder β€” Daily Dose Tracker PWA β€” and compare it with your own code.

1. What Our Medicine Reminder App Will Do

Before writing code, fix the feature list. A focused first version beats a half-finished big one. Our app will let the user add a medicine with its name, dose (for example, 1 tablet), time of day and a short note such as "after food". It will show today's schedule in time order, let the user mark each dose as taken, and keep a simple history so a family member can check whether the morning dose was actually taken. Everything is stored in the browser with localStorage, so the data stays on the device and works offline.

We will also add two touches that make it feel like a real app. First, a "next dose" banner at the top that always shows what is coming up and in how long. Second, PWA support β€” a manifest file and a service worker β€” so the app can be installed on an Android home screen and opened like a native app. That matters in India, where many users prefer a home-screen icon over opening a browser and typing a URL every time.

2. Step 1: Build the HTML Structure

Start with a single index.html file. The page needs three blocks: a header with the next-dose banner, a form for adding a medicine, and a list where today's doses appear. Keep the form fields simple and use proper input types β€” type="time" gives you a native time picker on mobile for free, which is far easier for elderly users than typing "08:00" by hand.

<form id="medForm">
  <input id="medName" placeholder="Medicine name" required>
  <input id="medDose" placeholder="Dose, e.g. 1 tablet">
  <input id="medTime" type="time" required>
  <input id="medNote" placeholder="Note, e.g. after food">
  <button type="submit">Add Reminder</button>
</form>
<ul id="doseList"></ul>

Notice what is not here: no login, no account, no server. For a family medicine tracker, that is a feature, not a limitation. Health data never leaves the phone, there is no password for a parent to forget, and the app opens instantly. If you later build this for a clinic or a client, you can add accounts then β€” but start with the version people will actually use daily.

3. Step 2: Style It for Real Phones

Medicine apps are used by people who may not have perfect eyesight, often in bright light, sometimes with one hand. Design for that reality: large tap targets (at least 48 pixels tall), high-contrast text, a base font size of 16 pixels or more, and a clear visual difference between a pending dose and a taken one β€” for example, a green tick and slightly faded text once marked taken. Avoid tiny grey text for important information like the dose time.

Use a mobile-first layout with a maximum width around 480 pixels centred on larger screens, so the same page looks like an app on a phone and stays tidy on a laptop. A simple card design works well: each dose is a white card with the time in bold on the left, the medicine name and dose in the middle, and a big "Taken" button on the right. Test your design at 360 pixels wide β€” that is still a very common Android screen width in India β€” and make sure nothing overflows or wraps awkwardly.


4. Step 3: Add the JavaScript Engine

The JavaScript has four jobs: store medicines, render today's list, handle the "taken" action, and work out the next dose. Keep all data in one array and save it to localStorage after every change. Each medicine is a small object with an id, name, dose, time and note. When the page loads, read the array back; if nothing is stored yet, start with an empty list or one sample entry so first-time users understand the format.

let meds = JSON.parse(localStorage.getItem('meds') || '[]');

function save() {
  localStorage.setItem('meds', JSON.stringify(meds));
}

function render() {
  const list = document.getElementById('doseList');
  list.innerHTML = '';
  [...meds].sort((a, b) => a.time.localeCompare(b.time))
    .forEach(med => {
      const li = document.createElement('li');
      li.textContent = med.time + ' β€” ' + med.name + ' (' + med.dose + ')';
      list.appendChild(li);
    });
}

Two details here are worth learning properly. First, sorting by the time string works because the time input always returns 24-hour "HH:MM" format, which sorts correctly as plain text. Second, building list items with textContent instead of injecting raw HTML protects you from broken layout or script injection if someone types angle brackets into a medicine name. It is a small habit that separates careful developers from copy-paste coders, and clients notice it.

For the "taken" feature, store the date on which each dose was marked, not just a true/false flag. That way, tomorrow the same medicine automatically shows as pending again, while today's history remains available. A common beginner bug is a checkbox that stays ticked forever; storing a date string like "2026-12-04" and comparing it with today's date fixes that cleanly.

5. Step 4: Reminders, Notifications and the Next-Dose Banner

A reminder app that never reminds is just a list. The simplest reliable approach inside a web page is a timer that checks every 30 seconds whether any dose time has arrived and has not been marked taken, then shows an on-screen alert banner. Browsers also offer the Notification API, which can show a system notification after the user grants permission β€” ask for that permission only after the user adds their first medicine, not on page load, so the request makes sense in context.

Be honest with users about one limitation: a plain web page cannot guarantee a notification if the browser is fully closed and the phone has killed the app. That is true of every PWA, and it is why the next-dose banner matters β€” whenever the app is opened, the most important information is the first thing on screen. For most families, the combination of a home-screen icon, a clear schedule and in-app alerts is more than enough, and it costs nothing to run.

6. Step 5: Turn It Into an Installable PWA

Two files turn your page into an installable app. The manifest.webmanifest file declares the app name, theme colour and icons, and a small service worker caches the HTML, CSS and JavaScript so the app opens offline β€” useful in areas with patchy connectivity or when travelling. Register the service worker from your main script, and serve the files over HTTPS, which most hosting already provides.

Once installed, the app gets its own home-screen icon and opens full-screen without browser bars. For a parent who struggles with browsers, that single icon is the difference between an app they use every day and a link they lose. If you build small tools for local businesses β€” a clinic, a pharmacy, a tiffin service β€” this same PWA pattern lets you deliver an "app" without Play Store fees or app-review delays, which is a genuinely sellable skill in the Indian freelance market.


7. Common Mistakes and Easy Upgrades

Three mistakes show up in almost every first version. The first is forgetting to re-render the list after adding or deleting a medicine, so the screen and the data disagree. The second is storing times in 12-hour format with AM/PM text, which breaks sorting β€” always store 24-hour time and only format it for display. The third is skipping validation, allowing an empty name or a missing time to create a broken entry that confuses the whole schedule.

Once the basics work, upgrades are straightforward: multiple times per medicine (morning and night from one entry), a weekly history view for doctor visits, a refill reminder when a strip is about to finish, or a share button that sends today's schedule to a family WhatsApp group. Add one feature at a time and test it with a real user β€” ideally the person who will actually take the medicines. Their feedback will improve the app faster than any tutorial.

Frequently Asked Questions

Do I need a backend or database for a medicine reminder app?

No. For a personal or family app, localStorage in the browser is enough. Data stays on the device, works offline and costs nothing to host. You only need a backend if you want accounts, sync across devices or a doctor dashboard.

Will reminders work if the phone is locked or the browser is closed?

In-app alerts and browser notifications work while the app or browser is running. A PWA cannot guarantee background alerts on every phone if the system kills it, so keep the home-screen icon handy and check the next-dose banner when you open the app.

Can elderly parents use this app easily?

Yes, if you design for them: big buttons, large text, a native time picker and one clear "Taken" action per dose. Install it on their home screen once, add their medicines yourself, and they only need to tap one button at each dose time.

Can I use this project in my portfolio or for a client?

Absolutely. It demonstrates forms, localStorage, time logic and PWA skills in one small project. Customise the colours, add a clinic name or a refill feature, and it becomes a credible demo for pharmacies, clinics and local health businesses.

Download the Ready-Made Free Source Code

You now understand how a medicine reminder app is put together: a simple form, a sorted daily schedule, localStorage for private on-device data, taken-dose tracking by date, and PWA files for home-screen installation. Building it yourself is the best way to learn β€” but if you want a working version today, or a clean base to customise for a client, download the free source code from CodeFree: Mobile Medicine Reminder β€” Daily Dose Tracker PWA (HTML/CSS/JS). It is free, works offline, and you can host it anywhere in minutes.

Found this useful?
Share it with your team.

Keep reading

All posts