Skip to content

Types

ContextOptions ​

Defined in: createContext.js:2

Options for createContext.

Properties ​

PropertyTypeDescription
attributes?WebGLContextAttributesPassed to getContext.
autoResize?booleanResize the canvas when its CSS size changes. Defaults to true.
canvas?HTMLCanvasElementExisting canvas to use; size it with CSS.
container?HTMLElementWhere a new canvas is appended. Defaults to document.body.
dpr?numberFixed pixel ratio. By default follows devicePixelRatio, capped at 2, including when it changes (zoom, moving to another display).
onResize?(width, height, gl) => voidCalled with the new pixel size, once on creation and after every resize.
signal?AbortSignalStops resizing when aborted, and removes the canvas if createContext created it. A canvas you pass in is kept, and so is its context: getContext returns the same one if it's used again (as React's StrictMode does when it remounts).