CatalogPersonal life ›Wellbeing

Daily Habit Tracker — with automatic streaks

Building a habit is a matter of consistency, and seeing your own streak of consecutive days is the simplest way to stay motivated. Here you log every time you do a habit — drinking two liters of water, reading twenty minutes, meditating — and the app works out how many days in a row you've kept it up, with no account and no data leaving your device.

▶ Use this app

habitsstreakhabit trackerconsistencywellness

What it records

  • e.g. Drink 2L of water, Read 20 minutes

How it works

This is a Reactive app: a plain text document that your browser turns into a working app — forms, live data, tables, statistics and even charts, with nothing to install or configure.

  1. Use it right away. Hit “Use this app”: it opens right in your browser, ready to go, with data saved only on your device.
  2. Your data stays yours. Everything is stored locally on your device, kept separate for each app: no account, no server, nothing to set up.
  3. Make it your own. The text below is the entire app: copy it, tweak fields, views and words, and your changes become interactive instantly.
  4. Share it as a file. An app is a simple file: save it, export it or share it with a link; and with encrypted collaboration several people edit the same data in real time.
The app’s source
# 🔥 Daily Habit Tracker

Building a habit is a matter of consistency, and seeing your own streak of
consecutive days is the simplest way to stay motivated. Here you log every
time you do a habit — drinking two liters of water, reading twenty minutes,
meditating — and the app works out how many days in a row you've kept it up,
with no account and no data leaving your device.

::::form{path="checkins" id="fch"}
::input{form="fch" field="habit" placeholder="e.g. Drink 2L of water, Read 20 minutes" required="true"}
::input{form="fch" field="date" type="date" legend="Date" help="the day you did it, usually today" required="true"}
::add-form{form="fch" path="checkins" label="Mark done"}
::::

## Streak per habit

:::python{data="checkins"}
```
from datetime import date, timedelta

rows = data["checkins"]
by_habit = {}
for r in rows:
    h = r.get("habit")
    d = r.get("date")
    if h and d:
        by_habit.setdefault(h, set()).add(date.fromisoformat(d))

if by_habit:
    today = date.today()
    for h in sorted(by_habit):
        days = by_habit[h]
        cursor = today
        note = ""
        if cursor not in days:
            note = " (not logged today yet)"
            cursor = cursor - timedelta(days=1)
        streak = 0
        while cursor in days:
            streak += 1
            cursor = cursor - timedelta(days=1)
        print(f"🔥 {h}: {streak}-day streak{note}")
else:
    print("Log your first habit to start building a streak.")
```
:::

## Check-in history

:::table{path="checkins" headers="Habit,Date" deletable="true" editform="fch"}
{habit} | {date}
:::

Track as many different habits as you like here: just reuse the same name
every time you log one, so the streak keeps growing instead of starting over.