Piplup
@piplup/cache-busterHooks

useReleaseStatus

Use the useReleaseStatus hook to detect when a new version of your app is available.

Usage

useReleaseStatus allows you to detect whether a new release is available and decide how your app should respond.

Basic example

import { useReleaseStatus } from '@piplup/cache-buster';

function App() {
  const status = useReleaseStatus({
    storageKey: 'RELEASE',
  });

  if (status === 'new-release') {
    return (
      <div>
        <p>New version available</p>
        <button onClick={() => window.location.reload()}>
          Refresh
        </button>
      </div>
    );
  }

  return <YourApp />;
}

Props

Prop

Type

Return value

The useReleaseStatus hook returns one of the following statuses: error, new-release, no-release or null.

On this page