useOnline
useOnline is a custom hook that detects whether the browser is online.
Online
const online = useOnline()
return (
<Badge colorScheme={online ? "green" : "red"}>
{online ? "Online" : "Offline"}
</Badge>
)
If you use this code, you need to add
"use client" to the top of the file.Usage
import { useOnline } from "@yamada-ui/react"
import { useOnline } from "@/components/ui"
import { useOnline } from "@workspaces/ui"
const online = useOnline()