Tinylib
DiscoverDocsSign in
Sign in
Tinylib
AboutDiscoverDocsMake an appPricingTermsPrivacyDeveloper TermsContact

Start

  • Quickstart
  • How Tinylib works

Guides

  • Data
  • Rooms and rules
  • Games
  • Friends
  • Places and links
  • Reminders and notifications
    • Set a reminder
    • Schedule once or on repeat
    • Time zones
    • Without a connection
    • List and cancel reminders
    • Notify a room's members
    • Handle a tap
    • Notification permission
    • Respect the user's switches
    • Test in development
  • Publishing
  • Errors and offline
  • Platforms

Client API

  • tinylib
  • tinylib.data
  • tinylib.rooms
  • tinylib.invitations
  • tinylib.friends
  • tinylib.places
  • tinylib.reminders
  • Types
  • tinylib-sdk/kits

Rules API

  • Kinds
  • ctx

Reference

  • tinylib.json
  • Command line
  • Limits

Plain text

  • llms.txt
  • llms-full.txt

Reminders and notifications

Your app can reach a user in two ways while it isn't open. Your client sets reminders for the user, for example a nudge to write each evening. Your rules notify one member of a room, for example when someone joins their game. Your app can't notify anyone else.

ReminderRoom notification
Sent by
Reminder
Your client, with tinylib.reminders.set
Room notification
Your rules, with ctx.notify
Reaches
Reminder
The user, on each of their devices
Room notification
One member, unless they have the room open
When
Reminder
At the time you set
Room notification
As soon as your rules send it
The user's switch
Reminder
Reminders
Room notification
Rooms
Declared in uses as
Reminder
"reminders"
Room notification
"notifications"
The user's device Tinylib's servers Tinylib (app or browser tab) Your client Local reminders System notifications each reminder once Reminders Room Your rules reminders.set sync goes off push ctx.notify tap Your code Tinylib
The user's device Tinylib (app or browser tab) Your client Local reminders System notifications each reminder once Tinylib's servers Reminders Room Your rules reminders.set goes off sync push ctx.notify tap Your code Tinylib

Set a reminder

To remind the user, call tinylib.reminders.set with a name you choose:

JavaScript
await tinylib.reminders.set('evening', { title: 'Time to write', text: 'How was today?', repeat: tinylib.reminders.daily('18:00'), address: 'today', })

At its time, the reminder shows on each of the user's devices that receive notifications, with your app's name and icon above your title and text.

Setting the same name again replaces that reminder. A user can have 32 of your app's reminders at once. Past that, set with a new name rejects with limit.

Schedule once or on repeat

A reminder has exactly one of at and repeat. For a one-off, give at a time on the device's clock as 'YYYY-MM-DDTHH:MM'. Or give it a timestamp in milliseconds from tinylib.now(), which follows Tinylib's clock rather than the device's:

JavaScript
await tinylib.reminders.set('dentist', { title: 'Leave for the dentist', at: '2027-03-04T14:30' }) await tinylib.reminders.set('tea', { title: 'Tea is ready', at: tinylib.now() + 4 * 60_000 })

repeat takes a schedule from daily, weekly, or monthly. The reminder starts at the next time the schedule matches:

JavaScript
await tinylib.reminders.set('standup', { title: 'Stand-up', repeat: tinylib.reminders.weekly(['mon', 'tue', 'wed', 'thu', 'fri'], '09:30'), }) await tinylib.reminders.set('rent', { title: 'Pay the rent', repeat: tinylib.reminders.monthly(1, '08:00') })

Time zones

A reminder set for a clock time keeps the time zone of the device that set it. One set for 6pm in Atlanta goes off at 6pm Atlanta time, wherever the user is and across clock changes. To move a reminder to the user's current time zone, set it again. list() gives each reminder's time zone as timeZone.

Without a connection

set, list, and cancel work offline. A reminder set offline still goes off on that device at its time: in Tinylib's Android app even while Tinylib is closed, and on the web while Tinylib is open in a tab. Once the device reconnects, the reminder reaches the user's other devices too. A guest has no other devices, so their reminder goes off only on the device that set it.

A device that can't show a reminder on time, for example because it was switched off, shows it up to 1 hour late, and otherwise skips it.

List and cancel reminders

JavaScript
const reminders = await tinylib.reminders.list() await tinylib.reminders.cancel('evening')

Each reminder in the list has what it was set with, plus next, when it next goes off. The user can also cancel reminders on your app's page in Tinylib, so call list() again each time a screen shows them.

For a daily reminder the user turns on and off in your app, followDailyReminder in tinylib-sdk/kits keeps your switch in step.

Notify a room's members

To tell a member something needs them while they're away, call ctx.notify in a handler with their id. Tinylib sends nothing while the member has the room open on any device, and never notifies a guest, who has no Tinylib account. Tapping the notification opens your app at the kind's address, so give the kind one:

rules.js
export const game = { address: 'game/:id', create(options, ctx) { return { board: Array(9).fill(''), players: { x: ctx.user.id, o: null }, turn: 'x', winner: null } }, join(state, via, ctx) { state.players.o = ctx.user.id ctx.notify(state.players.x, { title: `${ctx.user.name} joined`, text: 'Your move.' }) }, // ... }

Notify sparingly, when something waits on the member: it's their turn, or a list they shared is finished. Tell the member it waits on, not every member about every change; the others see it in the room's status and its view when they open it:

rules.js
export const list = { // ... actions: { check(state, item, ctx) { state.done[item] = true const finished = state.items.every((each) => state.done[each]) if (finished && ctx.user.id !== state.owner) ctx.notify(state.owner, { title: 'List done', text: `${ctx.user.name} finished it.` }) }, }, }

A member has one notification from a room at a time. A newer one replaces it and alerts again, so a member who missed three moves sees only the last. Opening or leaving the room clears it on that device and on the member's Android phones at once, and in another browser once the room opens there.

A title longer than 80 characters or a text longer than 300 characters isn't sent, and the error shows on the developer page. A room sends at most 60 per hour to one member and 300 per hour in all, and Tinylib drops the rest.

Handle a tap

Tapping a reminder or a room's notification opens your app at its address, or at your start screen when a reminder has none. If your app is already open, it keeps running and moves to that address, and tinylib.places.onChange calls your function.

Your app learns only the address, not what the user tapped, so route on it as Places and links shows. To tell a reminder's arrival from any other, put something in its address, for example today?from=evening.

Notification permission

Your app never asks for permission to notify. Tinylib asks, the first time your app sets a reminder or creates or joins a room on a device that hasn't been asked yet.

tinylib.user.settings holds your app's switches, not the device's permission. Platforms says which devices get notifications.

Respect the user's switches

Your client reads the switches as tinylib.user.settings.reminders and tinylib.user.settings.notifications, the field for Rooms. Both start on. Only the user changes them, on your app's page in Tinylib or in the sheet that tinylib.user.manageSettings() opens over your app. To offer the switch where the user expects reminders:

JavaScript
const turnOn = document.querySelector('#turn-on-reminders') function update() { turnOn.hidden = tinylib.user.settings.reminders } update() tinylib.user.onChange(update) turnOn.addEventListener('click', async () => { try { await tinylib.user.manageSettings() } catch (error) { toast(error.message) } })

While Reminders is off, none of your app's reminders goes off, though they stay set and set still works. A time that passes meanwhile is skipped: a repeating reminder moves on to its next time, and a one-off is gone.

While Rooms is off, or the user has muted a room, your rules' notifications don't reach them. tinylib.rooms.list() gives a room the user muted muted: true.

Test in development

In npx tinylib-sdk dev, each user's pane has a Notifications list of what would reach them, including what a switch or a muted room held back. Tapping one opens the app at its address. The clock's buttons skip ahead, so a reminder comes due without waiting.

PreviousPlaces and linksNextPublishing

On this page

  • Set a reminder
  • Schedule once or on repeat
  • Time zones
  • Without a connection
  • List and cancel reminders
  • Notify a room's members
  • Handle a tap
  • Notification permission
  • Respect the user's switches
  • Test in development