phaserjs/phaser · error · Error

Unknown value for renderer type:

Error message

Unknown value for renderer type: 

What it means

After the AUTO branch resolves and the WEBGL/CANVAS branches are checked, any other `renderType` value falls into the `else` at CreateRenderer.js:57 and throws with the offending value appended. This catches numeric values that are not one of the CONST renderer enums.

Source

Thrown at src/core/CreateRenderer.js:57

    //  Not a custom environment, didn't provide their own canvas and not headless, so determine the renderer:
    if (!config.customEnvironment && !config.canvas && config.renderType !== CONST.HEADLESS)
    {
        if (config.renderType === CONST.AUTO)
        {
            config.renderType = Features.webGL ? CONST.WEBGL : CONST.CANVAS;
        }

        if (config.renderType === CONST.WEBGL)
        {
            if (!Features.webGL) { throw new Error('Cannot create WebGL context, aborting.'); }
        }
        else if (config.renderType === CONST.CANVAS)
        {
            if (!Features.canvas) { throw new Error('Cannot create Canvas context, aborting.'); }
        }
        else
        {
            throw new Error('Unknown value for renderer type: ' + config.renderType);
        }
    }

    //  Pixel Art mode?
    if (!config.antialias)
    {
        CanvasPool.disableSmoothing();
    }

    var baseSize = game.scale.baseSize;

    var width = baseSize.width;
    var height = baseSize.height;

    //  Does the game config provide its own canvas element to use?
    if (config.canvas)
    {
        game.canvas = config.canvas;

View on GitHub (pinned to 41be1e462b)

Solutions

  1. Use the official enum constants: `Phaser.AUTO`, `Phaser.CANVAS`, `Phaser.WEBGL`, or `Phaser.HEADLESS`.
  2. Inspect the appended value in the message — it reveals the bad input immediately.
  3. Upgrade/audit the config against the current Phaser version's CONST module.

Example fix

// before
type: 'webgl' // string, not an enum
// after
type: Phaser.WEBGL
Defensive patterns

Strategy: validation

Validate before calling

const VALID = [Phaser.AUTO, Phaser.CANVAS, Phaser.WEBGL, Phaser.HEADLESS]
if (!VALID.includes(cfg.type)) {
  throw new Error(`Invalid renderType: ${cfg.type}. Use a Phaser.* constant.`)
}

Type guard

const isRenderType = (v) =>
  v === Phaser.AUTO || v === Phaser.CANVAS || v === Phaser.WEBGL || v === Phaser.HEADLESS

Prevention

When it happens

Trigger: Thrown at src/core/CreateRenderer.js:57 when the library encounters an invalid state.

Common situations: Using a constant that was renamed/removed across Phaser versions; passing `type: 'webgl'` (string) instead of `Phaser.WEBGL`; copy-pasting a config whose `type` field came from an unrelated library.

Related errors


AI-assisted analysis of phaserjs/phaser@41be1e462b (2026-08-13). Data as JSON: /api/errors/e6ad71e8aa7b406a. Report an issue: GitHub.