Skip to content
synccn

Network Status

New

Tells people when they go offline and when they're back, and exports useOnline() for your own logic.

Simulate offline

Your real connection: online

Installation

$ pnpm dlx shadcn@latest add @synccn/network-status

First time in this project? Connect synccn with one command.

Usage

import { NetworkStatus, useOnline } from "@/components/ui/network-status";<NetworkStatus />

API reference

Generated from the component's TypeScript types, so it always matches the code.

NetworkStatus

Tells people when they lose their connection, and briefly when it's back. Nothing shows while everything is fine. Also exports useOnline() for your own logic.

  • online
    boolean

    Overrides the detected state, e.g. for testing or when you check your own API's health.

  • position
    "fixed" | "inline"

    Default "fixed"

    "fixed" floats at the bottom of the window; "inline" sits where you put it.

  • offlineMessage
    string

    Default "You're offline. Changes will sync when you reconnect."

    Message while offline.

  • className
    string

    Extra classes for the root element.

useOnline

True while the browser has a network connection. Always true while server rendering.

Takes no props.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • Changes are announced through a polite status region.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: status
  • ARIA attributes: aria-live
  • Announces changes to screen readers