npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-connection-status

v0.9.2

Published

An Angular package for checking application connectivity.

Readme

ngx-connection-status

Is an Angular 6 package that provides a simple way to check your application's connectivity to its host server. The package relies on a service that basically pings the host to check connectivity and provides a hook that you can get feedback from.

Getting Started

Install the package in your project:

npm install ngx-connection-status --save

Import the package module in your project's root module (i.e app.module.ts):

import { NgxConnectionStatusModule } from 'ngx-connection-status';

Then add it to NgModule imports array:

@NgModule({
  ...,
  imports: [
    ...,
    NgxConnectionStatusModule.forRoot({'checkInterval: 5000'}),
    ...
  ],
  ...
})

The forRoot method is for providing the initial configuration of the service. Right now it accepts a checkInterval key with a value in milliseconds for setting the time interval between pings to the host.

hint: A good time interval would be no less than 5 seconds (5000 milliseconds), you don't want to flood the server with requests since the package service relies on pinging it. But let yourself be the judge of the appropriate time.

hint: A better practice than supplying the configuration object inline to forRoot would be saving it first in your environment.ts file and then importing it to the module.

Thats it! You are done setting the package up.

Setting Up The Server

Make sure your production host server accepts HEAD requests, otherwise you will always get a disconnected feedback.

angular-cli doesn't allow HEAD requests. So in development mode the app will be sending GET requests (but it will not work when serving with --prod).

Using The Component

The package offers a simple component that can be included in your views to provide connectivity feedback to the user.

To use it, simply add it in your HTML:

<ngx-connection-status></ngx-connection-status>

Positioning

You can also use the feedbackPosition directive to give the component a fixed position at one of four possible options:

  • top-right tr
  • bottom-right br
  • bottom-left bl
  • top-left tl

for example:

<ngx-connection-status [feedbackPosition]="'br'"></ngx-connection-status>

FontAwesome Support

If you are using FontAwesome (I don't know why you wouldn't be, It's awesome!) the component will add beautiful icons.

Currently supports version 5.

Hooking Up to The Service

Of course, you may want to use the service in ways other than provided by the component. This works by getting the service hook and subscribing to it.

  1. import the service to your component:
import { NgxConnectionStatusService } from 'ngx-connection-status/ngx-connection-status.service';
  1. inject it in the constructor:
constructor(private cs: NgxConnectionStatusService) { }
  1. get the hook and subscribe to it:
this.cs.statusHook().subscribe(isOnline => {
  if (isOnline) {
    //do stuff...
  } else {
    //do other stuff...
  }
});

A Little Background

You probably know that Javascript provides an API that is way easier to use and should do the job and that's window.navigator.onLine. However, it's extremely unreliable, the main reason being that it only checks for a possible network connection, not an actual existing one, which leads it, for example, to mistake virtual network adapters used by virtual machines or VPN clients for an active connection.

Liscence

ngx-connection-status is released under the MIT License.