README.md

June 24, 2026 ยท View on GitHub

NgxUpdateVersion

npm version Package License NPM Downloads Snyk stars forks HitCount

Angular directive for updating app via service workers

โœ“ Angular 22 compatible

Here's the demo

  • Lightweight
  • No dependencies!
  • Directive way
  • Customizable options...

๐Ÿ› ๏ธ Install

yarn add ngx-update-app

๐Ÿš€ Quick start

  1. Provide config
import { provideUpdateApp } from 'ngx-update-app';

export const appConfig: ApplicationConfig = {
  providers: [
    provideUpdateApp({
      interval: 1000 * 60, // check new version every minute
      dryRun: false, // set to true if you want to see alert on init
      onUpdateFactory: () => {
        // you can use inject() here
        return () => alert('Should update');
      }
    }),
    provideServiceWorker('ngsw-worker.js', { enabled: !isDevMode(), registrationStrategy: 'registerWhenStable:30000' })
  ]
};
  1. Use directive in root component
import { NgxUpdateAppDirective } from 'ngx-update-app';

@Component({ standalone: true, hostDirectives: [NgxUpdateAppDirective] })
export class AppComponent {}

๐Ÿ› ๏ธ Options

OptionTypeDefaultDescription
intervalnumberundefinedinterval to check new version in milliseconds
dryRunbooleanfalseforce update action once on init
onUpdateFactoryfunctionundefinedfunction which will be called on update

๐Ÿ”ง Compatibility

Angularngx-update-appInstall
>= 223.xyarn add ngx-update-app
>= 202.xyarn add ngx-update-app@2
>= 181.xyarn add ngx-update-app@1
>= 170.xyarn add ngx-update-app@0

๐Ÿ“ฆ Dependencies

None

๐Ÿชช License

Copyright ยฉ 2023 - 2026 Dominik Hladik

All contents are licensed under the MIT license.