Skip to main content

Application

The Application class provides a modern, extensible entry point to set up rendering in PixiJS. It abstracts common tasks like renderer setup and ticker updates, and is designed to support both WebGL and WebGPU via async initialization.

Creating an Application

Creating an application requires two steps: constructing an instance, then initializing it asynchronously using .init():

import { Application } from 'pixi.js';

const app = new Application();

await app.init({
width: 800,
height: 600,
backgroundColor: 0x1099bb,
});

document.body.appendChild(app.canvas);

ApplicationOptions Reference

The .init() method of Application accepts a Partial<ApplicationOptions> object with the following configuration options:

OptionTypeDefaultDescription
autoStartbooleantrueWhether to start rendering immediately after initialization. Setting to false will not stop the shared ticker if it's already running.
resizeToWindow | HTMLElementElement to auto-resize the renderer to match.
sharedTickerbooleanfalseUse the shared ticker instance if true; otherwise, a private ticker is created.
preference'webgl' | 'webgpu'webglPreferred renderer type.
useBackBufferbooleanfalse(WebGL only) Use the back buffer when required.
forceFallbackAdapterbooleanfalse(WebGPU only) Force usage of fallback adapter.
powerPreference'high-performance' | 'low-power'undefinedHint for GPU power preference (WebGL & WebGPU).
antialiasbooleanEnables anti-aliasing. May impact performance.
autoDensitybooleanAdjusts canvas size based on resolution. Applies only to HTMLCanvasElement.
backgroundColorSourceAlias for backgroundColor.
backgroundAlphanumber1Alpha transparency for background (0 = transparent, 1 = opaque).
backgroundColorColorSource'black'Color used to clear the canvas. Accepts hex, CSS color, or array.
canvasICanvasA custom canvas instance (optional).
clearBeforeRenderbooleantrueWhether the renderer should clear the canvas each frame.
contextWebGL2RenderingContext | nullnullUser-supplied rendering context (WebGL).
depthbooleanEnable a depth buffer in the main view. Always true for WebGL.
heightnumber600Initial height of the renderer (in pixels).
widthnumber800Initial width of the renderer (in pixels).
hellobooleanfalseLog renderer info and version to the console.
multiViewbooleanfalseEnable multi-canvas rendering.
preferWebGLVersion1 | 22Preferred WebGL version.
premultipliedAlphabooleantrueAssume alpha is premultiplied in color buffers.
preserveDrawingBufferbooleanfalsePreserve buffer between frames. Needed for toDataURL.
resolutionnumber1The resolution of the renderer.
skipExtensionImportsbooleanfalsePrevent automatic import of default PixiJS extensions.
textureGCActivebooleantrueEnable garbage collection for GPU textures.
textureGCCheckCountMaxnumber600Frame interval between GC runs (textures).
textureGCMaxIdlenumber3600Max idle frames before destroying a texture.
textureGCAMaxIdlenumber(Appears undocumented; placeholder for internal GC controls.)

Customizing Application Options Per Renderer Type

You can also override properties based on the renderer type by using the WebGLOptions or WebGPUOptions interfaces. For example:

import { Application } from 'pixi.js';

const app = new Application();
await app.init({
width: 800,
height: 600,
backgroundColor: 0x1099bb,
webgl: {
antialias: true,
},
webgpu: {
antialias: false,
},
});
document.body.appendChild(app.canvas);

Built-In Plugins

PixiJS includes:

  • Ticker Plugin — Updates every frame → Guide
  • Resize Plugin — Resizes renderer/canvas → Guide
  • Optional: Culler Plugin - Culls objects that are out of frame → Guide

Creating a Custom Application Plugin

You can create custom plugins for the Application class. A plugin must implement the ApplicationPlugin interface, which includes init() and destroy() methods. You can also specify the extension type, which is ExtensionType.Application for application plugins.

Both functions are called with this set as the Application instance e.g this.renderer or this.stage is available.

The init() method is called when the application is initialized and passes the options from the application.init call, and the destroy() method is called when the application is destroyed.

import type { ApplicationOptions, ApplicationPlugin, ExtensionType } from 'pixi.js';

const myPlugin: ApplicationPlugin = {
extension: ExtensionType.Application;
init(options: ApplicationOptions) {
console.log('Custom plugin init:', this, options);
},
destroy() {
console.log('Custom plugin destroy');
},
};

Register with:

import { extensions } from 'pixi.js';
extensions.add(myPlugin);

Adding Types

If you are using TypeScript, or are providing a plugin for others to use, you can extend the ApplicationOptions interface to include your custom plugins options.

declare global {
namespace PixiMixins {
interface ApplicationOptions {
myPlugin?: import('./myPlugin').PluginOptions | null;
}
}
}

await app.init({
myPlugin: {
customOption: true, // Now TypeScript will know about this option
},
});

API Reference