getRenderer
The getRenderer hook provides a way to access the root Pixi.Renderer instance created by the PixiApplicationProvider or PixiCanvas component.
This is useful when you need to interact directly with the Pixi.js renderer, for example, to access renderer properties or perform low-level rendering operations.
This hook must be called from a component that is a descendant of the <PixiApplicationProvider /> or <PixiCanvas /> component.
If used outside of this context, it will throw an error.
import { getRenderer, Container, PixiCanvas } from "pixi-solid";import { createEffect } from "solid-js";
const MyComponent = () => { const renderer = getRenderer();
createEffect(() => { // You can now safely use the Pixi.js Renderer instance console.log("Renderer resolution:", renderer.resolution); console.log("Renderer view size:", renderer.width, renderer.height); });
return <Container>{/* Your components here*/}</Container>;};
export const DemoApp = () => { return ( <PixiCanvas> <MyComponent /> </PixiCanvas> );};When to use it
Section titled “When to use it”- When you need direct access to the
Pixi.Rendererinstance for advanced rendering operations. - To query renderer properties such as resolution, or rendering context.
- When you need to perform operations that are specific to the renderer and not covered by other
pixi-solidutilities.
Relationship to other hooks
Section titled “Relationship to other hooks”getPixiAppgives you access to thePixi.Applicationinstance, which contains the renderer as a property. You can access the renderer viagetPixiApp().renderer.getRendereris a convenience hook that directly accesses the renderer without needing to go through the application instance.
Further reading
Section titled “Further reading”- Read more about the
Pixi.Rendererclass in the PixiJS documentation.