documentSize() returns a non-reactive { width, height } snapshot
of the document element's size — it reads
documentElement.clientWidth and clientHeight once and does not
track. For a reactive accessor that re-runs effects on every window
resize, use useDocumentSize. Part of
pota/use/resize.
documentSize() takes no arguments.
Returns: { width: number, height: number } — the viewport
dimensions at the moment of the call.
Calls documentSize() once on render and shows the static dimensions.
Because the value is a plain snapshot, it does not update on resize —
reach for useDocumentSize when you
need that.
import { render } from 'pota'
import { documentSize } from 'pota/use/resize'
function App() {
const { width, height } = documentSize()
return (
<p>
viewport: {width}×{height}
</p>
)
}
render(App)