10LOC

#pwa

Chrome APIsadvanced

Periodic Background Sync for resilient refresh jobs

type PeriodicSyncRegistration = ServiceWorkerRegistration & {
  periodicSync: { register: (tag: string, options: { minInterval: number }) => Promise<void> };
};

export const schedulePeriodicRefresh = async (tag: string, minIntervalMs: number): Promise<boolean> => {

Schedule light refresh work that can survive transient network loss.

Web Platformintermediate

Persist storage with navigator.storage.persist

export const ensurePersistentStorage = async (): Promise<boolean> => {
  if (!navigator.storage?.persist) return false;
  if (await navigator.storage.persisted()) return true;
  return navigator.storage.persist();
};

Ask the browser for persistent storage so your app can keep data around longer.

Chrome APIsadvanced

The File Handling API for browser file access

type LaunchParams = { files: FileSystemFileHandle[] };
type LaunchQueue = { setConsumer: (consumer: (params: LaunchParams) => void) => void };

export const handleLaunchedFiles = (onFiles: (files: File[]) => void): void => {
  const launchQueue = (window as { launchQueue?: LaunchQueue }).launchQueue;

Open and work with files directly from the browser with the File Handling API.