Installable app
Every app built with protobase build can be installed from the browser, as a Progressive Web App: Chrome and Edge offer Install in the address bar, Android’s browsers Add to home screen, and Safari on iPhone and iPad Share > Add to Home Screen. The installed app opens in a window of its own, without the browser’s toolbars, at the app’s home page.
There is nothing to set up. The app installs under its name, PROTOBASE_APP_NAME or name in protobase.config.ts, with its favicon, protobase.favicon.svg, as its icon, and the colours themeColor and backgroundColor of the config (see App identity). Safari takes no SVG icon: give the project a protobase.apple-touch-icon.png, or it shows a picture of the page on the home screen instead.
The manifest
Section titled “The manifest”The app’s page links its web app manifest at /api/manifest.webmanifest, which the server answers to anyone, without a token:
{ "name": "Property Finder", "short_name": "Property Finder", "id": "/", "start_url": "/", "scope": "/", "display": "standalone", "theme_color": "#0d9488", "background_color": "#ffffff", "icons": [ { "src": "/protobase.favicon.svg", "sizes": "any", "type": "image/svg+xml" }, { "src": "/protobase.icon-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "/protobase.icon-512.png", "sizes": "512x512", "type": "image/png" }, { "src": "/protobase.icon-maskable.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } ]}The colours and each PNG are there only when the project has them.
Without a network
Section titled “Without a network”The data stays online: the installed app reads and writes through the API as the browser tab does, and nothing can be changed offline. Someone signed in sees the pages they opened last, from the start cache, with a warning beside the title that they could not be refreshed. The page registers a service worker, /protobase.sw.js in the bundle’s public/, which keeps only the app itself, so the app still opens without a network and says it cannot reach the server.
- A page always comes from the server while it answers, and from the cache only when the network fails.
- The files under
/assets, named by their content, come from the cache once loaded. The page and what it loads first are cached when the worker installs. - The theme and the favicon come from the server, with the cached copy used when the network fails.
- Nothing else is cached by the worker: the API, the plugins and other sites go to the network as without the worker.
Each build of the app has its own worker, which replaces the previous one and drops its cache on the next visit. protobase dev registers no worker, so the dev server’s changes always show.
Starting from the last pages seen
Section titled “Starting from the last pages seen”The app keeps what someone signed in last saw, from the moment they sign in, and opens on it the next time, in the browser tab, the installed app and the iOS and Android app alike. Before it draws, the app reads this start cache and loads the plugins its /meta names, which the browser usually has cached, at most 10 seconds; then its first frame is the whole page, drawn from the cache: a list with its rows, a record with its fields, a page with its blocks, with no skeleton or spinner in place of anything the cache holds. Everything on it is fetched again behind it:
- While the cached data is fetched again, a small spinner sits beside the page’s title. The page itself stays as it was drawn.
- When the fresh data lands it replaces the cached data in place, and nothing moves.
- When the refresh fails, such as without a network, the cached data stays, muted, and a warning replaces the spinner.
The start cache holds who is signed in, the app’s /meta and the latest answer of each query the app read. It has no time limit, only a soft limit of 4 MB: once the answers pass it, those used least recently are dropped, oldest first, until they are back under it. Who is signed in, /meta and the answers of the page on screen when it saves are never dropped, so the next start draws that page whole: the cache can pass 4 MB by that one page. A table embedded in a page reads only the fields it shows, which keeps the page small, unless its actions run on selected rows: those get whole records. It lives in the browser’s IndexedDB for the app’s origin, or in the app’s own storage on a phone. It is emptied when someone signs out, when the session ends and the API answers 401, and when a new Protobase version of the app opens. Visitors and staff signed in as someone keep nothing. /meta per organization in the start cache is not implemented, so it draws the last one’s, muted, until /meta is read again.
When the UI is ready
Section titled “When the UI is ready”Once the app has drawn its first page, as it takes its start screen away, and the browser has painted that frame, it dispatches a protobase:ui-ready event on window (uiReadyEvent of @protobase/ui). With a warm start cache that is the app’s first commit. A host that loads the app out of sight shows it then, so the page appears whole instead of blank: Protobase’s official app loads a workspace behind the one on screen and swaps them on this event.