Skip to Content
React Flow 13 is here! Read the announcement →
ReferenceTypes

ViewportStore

Source on GitHub 

The viewport store is a slice of React Flow’s state returned by the useViewportStore() hook. You might use this in a node to access the current zoom level and dynamically adjust the node’s content, for example.

import { useViewportStore, type ViewportStore } from '@xyflow/react'; const zoomSelector = (state: ViewportStore) => state.transform[2]; export function ViewportLookup() { const zoom = useViewportStore(zoomSelector); return ( <div> <p>{zoom > 1 ? 'Zoomed in' : 'Zoomed out'}</p> </div> ); }
NameTypeDefault
paneDraggingboolean
transformTransform
widthnumber
heightnumber