use-mounted
Whether the calling component has mounted.
| Package | @vizejs/composable/use-mounted |
| Own the source | vize lib pull composable:use-mounted |
| Runtime exports | useMounted |
| Gzip budget | 768 B |
Usage
import { useMounted } from "@vizejs/composable/use-mounted";
Runtime contract
| Utility | Category | Stability | SSR | Hydration | Cleanup | Targets | Host globals | Uses |
|---|---|---|---|---|---|---|---|---|
useMounted |
lifecycle | experimental | safe | stable | none | web, server, worker, native, desktop, terminal | — | — |
API
useMounted
Whether the calling component has mounted. false during server rendering and during hydration, true from the component's onMounted on: gate client-only rendering behind it to keep hydration stable. Outside a component (no instance to mount) it stays false. Component detection uses hasInjectionContext() rather than getCurrentInstance(), which returns null inside Vapor components, so the flag also flips in Vapor.
function useMounted(): Readonly<ShallowRef<boolean>>
const mounted = useMounted();
// <ClientOnlyChart v-if="mounted" />