Skip to content

Release 1.0.0: update prompt, Next.js support and a live demo - #7

Merged
devmaxxx merged 8 commits into
masterfrom
feat/update-prompt
Oct 16, 2026
Merged

devmaxxx merged 8 commits into
masterfrom
feat/update-prompt

Conversation

@devmaxxx

@devmaxxx devmaxxx commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Prepares 1.0.0. See CHANGELOG.md for the full list and README "Upgrading from 0.x" for the breaking changes.

  • onUpdate ('prompt' | 'reload' | 'flag') decides what a check that finds a newer build does; auto stays as a deprecated alias.
  • prompt takes the app's own component (UpdatePromptProps); the library ships no dialog, the demo has one to copy. promptOnChunkError asks before reloading for chunk errors.
  • reloadWhenHidden, canReload, blocking={false}, and an immediate check when focus returns after a whole duration.
  • Next.js: 'use client' bundle, storage read after mount (server render and hydration without mismatch), Turbopack chunk errors recognised. Verified in a Next 15.5 + Turbopack app.
  • 0.2 code compiles and behaves as before; lazyRetry keeps its 0.x attempt count.
  • GitHub Pages demo with simulated deploys, radio-group settings and a redesigned dialog.

Breaking: React 18+, entry points through exports, stored version saved only on reload, lazyRetry(fn, 0) makes one attempt, debug receives error: unknown.

Tests: 70 unit, 33 e2e (Chromium, Firefox, WebKit, demo).

ClearBrowserCacheBoundary takes an `updatePrompt` element or component and
shows it when polling finds a newer build and `auto` is off, so the app can
ask before reloading instead of only flipping `isLatestVersion`. With
`promptOnError`, a stale-chunk error shows the prompt over `fallback` rather
than reloading at once; dismissing it hands the error to the parent boundary.
The context gains `dismissUpdate`, which hides the prompt until a newer build.

The package also exports `UpdatePrompt`, an unstyled native <dialog> that
focuses Reload, dismisses on Escape or Later, locks while reloading and
restores focus when it goes away.
The example app built with VITE_DEMO=1 becomes an interactive playground:
a "Deploy new version" button, live boundary props, the tab's version and
Cache Storage state, and an event log that survives reloads. GitHub Pages
serves static files only, so a fetch shim answers meta.json with a version
kept in localStorage; the version check, cache clearing and reload run
through the library unchanged.

A Pages workflow publishes it from master, replacing the gh-pages script.
Playwright serves the demo under the same sub-path as Pages and covers the
dialog, the stale-chunk path and a custom banner prompt. The library is
built once before Playwright starts, since two webServer builds racing on
dist would be flaky.
…hooting

Lead with the problem and a demo screenshot, list features, and add a table
of contents, a three-step quick start, a flow diagram, a full API section,
recipes and collapsible troubleshooting. Replace the inaccurate standard-style
badge with CI, downloads, bundle size, types and license badges.
…ing mount

- Check at once when a tab gets focus back after a whole `duration`,
  instead of waiting another interval on a stale build.
- `reloadWhenHidden` reloads into a newer build as soon as the tab goes to
  the background, so users never see the switch.
- `canReload` is asked before every reload the user did not start (`auto`,
  `reloadWhenHidden`); a throwing guard counts as a no.
- `blocking={false}` renders the app at once and checks in the background.

The demo gains controls for the new options, and the README documents them
with a reload-on-navigation recipe.
… while hidden

The guard ran in checkVersion's default parameter, before the fetch and on
every poll, so its answer could be stale by the time a reload happened.
A check that resolved after the tab went to the background never reloaded,
because visibilitychange had already fired. Polling restarts only when
`duration` changes, since `auto` is read at check time.
… demo

Rename the update API to one strategy prop: onUpdate ('prompt' | 'reload' |
'flag') with prompt and promptOnChunkError; auto stays as a deprecated alias.
The library no longer ships a dialog component: prompt takes the app's own
component, and the demo's UpdateDialog is an example to copy.

Read the stored version after mount so the boundary renders on the server and
hydrates without a mismatch, mark the bundle 'use client', and recognise
Turbopack chunk errors. With reloadWhenHidden and duration, going to the
background checks once, so a deploy since the last poll is reloaded into.

lazyRetry keeps its 0.x meaning: the second argument counts attempts in all,
two by default, and 0 makes one attempt instead of retrying forever. The 0.x
ClearBrowserCacheAppVersionStorage type is exported again as deprecated.

The demo uses radio groups for duration, onUpdate and the prompt, a compact
layout, and a redesigned dialog.
@devmaxxx devmaxxx changed the title Add an update prompt for new builds and a live GitHub Pages demo Release 1.0.0: update prompt, Next.js support and a live demo Oct 16, 2026
@devmaxxx
devmaxxx merged commit 78ace75 into master Oct 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant