Places and links
tinylib.places names each screen in your app by its address: the page's path without its leading /, plus any query string. At /game/abc?tab=moves, the address is game/abc?tab=moves. The address leaves out any # fragment, and the empty address, '', is your start screen.
Your app runs on its own origin, and Tinylib serves your index.html at every path that isn't one of your published files. A router that uses the browser's History API, such as React Router, works without a basename:
Without a router, read tinylib.places.address when your page starts, and again each time it changes:
onChange runs after every change of address, including the ones Tinylib makes. When the user accepts an invitation while your app is open, Tinylib takes them to the room's address and onChange runs. For a game with a list of games and one game screen, route in tinylib-sdk/kits does this routing for you.
tinylib.places.go changes screens without loading a new page:
After a tap, back returns the user to the screen they left. A move with no tap, such as a redirect from a screen your app refuses, takes the current screen's place, so back never returns to a screen that would only send them away again. replace does the same after a tap.
A move to your start screen goes back to it when it's beneath, and otherwise takes the current screen's place.
go throws a TypeError for an address that starts with /.
Back leaves your app from the screen it opened at. To offer a way out from any screen, draw your own button and call tinylib.places.exit from its tap, which takes the user to their Library. It rejects with refused with no tap, or while one of Tinylib's sheets is open:
A link to a path in your app changes screens as go does. A link to another site opens in a new tab on the web, and in the phone's browser in Tinylib's Android app.
tinylib.places.share opens the device's share sheet with a link to a screen, or Tinylib's own sheet where the device has none:
The link is your app's slug and the address, such as https://tinylib.app/groceries/list/abc. Anyone can open it, with or without a Tinylib account. The first time, the user taps Open: a user new to Tinylib gives their name there, and an app that uses friends says so there.
A shared link doesn't let anyone into a room, because a room shows only to its members. To add someone, invite them with tinylib.rooms.invite or share the room's link from tinylib.rooms.getLink.
Tinylib opens your app at an address when the user:
- taps a reminder: the reminder's
address - taps a room's notification, picks a room in Tinylib's lists of rooms, or joins a room by an invitation or its link: the address of the room's kind
- opens a link to your app: the address in the link
Each kind's address in your rules sets where its rooms open, with :id replaced by the room's id:
:id can go anywhere in the address, for example '?list=:id'. A kind with no address opens your start screen, and your app can't tell which room the user came for.