Skip to content

getPixiApp

The getPixiApp hook provides a way to access the root PIXI.Application instance created by the PixiApplicationProvider or PixiCanvas component. This is useful when you need to interact directly with the Pixi.js application, for example, to access the renderer.

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 { getPixiApp, Container, PixiCanvas } from "pixi-solid";
import { createEffect } from "solid-js";
const MyComponent = () => {
const app = getPixiApp();
createEffect(() => {
// You can now safely use the Pixi.js Application instance
console.log("Pixi.js Application instance:", app);
});
return <Container>{/* Your components here*/}</Container>;
};
export const DemoApp = () => {
return (
<PixiCanvas>
<MyComponent />
</PixiCanvas>
);
};
  • When you need direct access to the PIXI.Application instance to perform operations not covered by specific pixi-solid components.
  • To get information about the Pixi.js renderer, such as its dimensions, resolution, or view.