@lhagfoss/local-time
v0.1.0
Published
A small, hydration-safe local time component and hook for React.
Maintainers
Readme
@lhagfoss/local-time
A small, dependency-light React component and hook for displaying live local time. It is hydration-safe, inherits your styles, and supports any IANA timezone.
Install
bun add @lhagfoss/local-timeComponent
import { LocalTime } from "@lhagfoss/local-time";
export function FooterTime() {
return <LocalTime timeZone="Europe/Oslo" prefix="Local time · " />;
}Use showSeconds, showTimeZone, locale, updateInterval, and normal <time> element props to customize the output.
Hook
import { useLocalTime } from "@lhagfoss/local-time";
const now = useLocalTime({ updateInterval: 1_000 });The initial value is null until the component mounts, preventing server/client timezone differences from causing hydration errors.
