getClientWidth
Commons
stable
Returns the viewport width (window.innerWidth) in a browser context, or the SSR-provided clientWidth fallback when running server-side.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- ssrTSSROptions
- Optional SSR options object. When provided as an object with a clientWidth property, that value is returned instead of window.innerWidth.
API
Return value
The value returned by this util.
- The viewport width in pixels. Returns 0 when running server-side without an SSR options object.
Usage
Examples
Ready-to-paste usage snippets.
Viewport width in browser vs SSR