@softr/sdk
Version:
The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.
35 lines • 1.32 kB
TypeScript
//#region src/offline.d.ts
type OfflineMode = {
/**
* `false` while the browser has no connection, or while the app shows saved
* copies because it cannot reach the server. Always `true` during server rendering.
*/
online: boolean;
};
type OfflineModeOptions = {
/**
* `false` turns offline mode off and deletes what this browser kept. Keep the
* call with `false` rather than removing it: browsers that ran offline mode
* before keep the visitor's copies, and keep saving new ones, until this runs
* or the visitor signs out. Defaults to `true`.
*/
enabled?: boolean;
};
/**
* Lets the published app open without internet and show the pages and data
* the visitor loaded, read only. Saves made offline fail as usual.
*
* Call it once, in the root route's `RootDocument`. The saved copies are
* deleted when another visitor signs in on this browser, or when the visitor
* signs out. In the Studio preview it only reports `online`.
*
* @example
* function OfflineBanner() {
* const { online } = useOfflineMode()
* if (online) return null
* return <div role="status">You're offline. Showing the last saved data.</div>
* }
*/
declare function useOfflineMode(options?: OfflineModeOptions): OfflineMode;
//#endregion
export { OfflineMode, OfflineModeOptions, useOfflineMode };