Skip to content

Application Settings ​

Blits provides a flexible and performant way to configure your application at launch using the settings object passed to Blits.Launch. These settings allow you to fine-tune rendering, performance, input, fonts, and more.

Below is a comprehensive overview of the available settings you can provide to a Blits Application:

Basic Settings ​

SettingTypeDescription
wnumberWidth of the application (canvas)
hnumberHeight of the application (canvas)
debugLevelnumber | string[]Debug level for console log messages
multithreadedbooleanEnable multithreaded rendering

Fonts & Text ​

SettingTypeDescription
fontsFont[]Array of font objects to register
defaultFontstringDefault font family to use

Example font object:

js
{
  family: 'lato',
  type: 'msdf', // or 'web'
  file: 'fonts/Lato-Regular.ttf',
}

Rendering & Performance ​

SettingTypeDescription
renderQuality'low' | 'medium' | 'high' | 'retina' | numberControls render quality (1 = 100%)
screenResolution'hd' | 'fhd' | '4k' | numberSets device screen resolution
pixelRationumberCustom pixel ratio (overrides screenResolution)
canvasColorstringBackground color of the canvas
fpsIntervalnumberInterval (ms) for FPS updates (0 disables)
webWorkersLimitnumberMax number of web workers for image handling
gpuMemoryobjectGPU memory management (see below)
gpuMemoryLimitnumber(Deprecated) Use gpuMemory instead
textureProcessingTimeLimitnumberMax ms per frame for texture processing
viewportMarginnumber | [number,number,number,number]Extra margin for preloading elements
advancedobjectAdvanced renderer settings (use with care)

GPU Memory Example ​

js
{
  max: 200, // MB
  target: 0.8, // 80% of max
  cleanupInterval: 5000, // ms
  baseline: 25, // MB
  strict: false
}

Input & Focus ​

SettingTypeDescription
keymapobjectCustom key mapping for input events
holdTimeoutnumberTime (ms) to consider a key press as hold
inputThrottlenumberInput throttle time (ms) to prevent rapid successive inputs
enableMousebooleanEnable mouse support (hover and click-to-focus). Defaults to false.
mouseMoveThrottlenumberMinimum time (ms) between pointer moves processed for hover; moves arriving sooner are dropped. Defaults to 100.

Renderer ​

SettingTypeDescription
renderMode'webgl' | 'canvas'Renderer mode (default: 'webgl')
canvasHTMLCanvasElementCustom canvas to render to
rendererPlatformobjectCustom platform configuration passed to the renderer

Platform ​

SettingTypeDescription
platformfunctionCustom platform capabilities used by Blits

The platform setting can be used when Blits is not running in a regular browser environment, or when you want to provide custom platform specific implementations.

The function receives the default browser platform as first argument, and should return the platform parts you want to override. All other platform functions will keep using the default browser implementation.

js
Blits.Launch(App, 'app', {
  platform: (defaults) => ({
    screenHeight: screen.height,
    input: {
      addEventListener(type, listener, options) {
        if (type === 'keydown') {
          myInput.on('keydown', listener)
          return
        }

        defaults.input.addEventListener(type, listener, options)
      },
      removeEventListener(type, listener, options) {
        if (type === 'keydown') {
          myInput.off('keydown', listener)
          return
        }

        defaults.input.removeEventListener(type, listener, options)
      },
    },
  }),
})

Common platform properties that can be overwritten are input, viewport, dispatchEvent, localStorage, getCookie, setCookie, historyBack, screenHeight, hardwareConcurrency, userAgent, KeyboardEvent, isKeyboardEvent, createKeyboardEvent, announcer, and now.

The announcer platform property can be used to provide a custom text-to-speech driver. When set, Blits keeps using the built-in announcer queue and calls the custom driver's speak(options) and cancel() methods instead of the default Web Speech implementation.

js
Blits.Launch(App, 'app', {
  announcer: true,
  platform: (defaults) => ({
    announcer: {
      speak(options) {
        return myPlatformSpeech.speak(options.message)
      },
      cancel() {
        myPlatformSpeech.cancel()
      },
    },
  }),
})

For LG webOS apps, Blits provides a webOS announcer factory that calls the platform TTS service.

js
import createAnnouncer from '@lightningjs/blits/platforms/webOS/announcer'

Blits.Launch(App, 'app', {
  announcer: true,
  platform: () => ({
    announcer: createAnnouncer(),
  }),
})

For platforms with a screen reader, Blits also provides a DOM announcer. It maintains a single visually hidden aria-live="assertive" region and updates its text for every announcement. The live region does not take DOM focus.

js
import createAnnouncer from '@lightningjs/blits/platforms/dom/announcer'

Blits.Launch(App, 'app', {
  announcer: true,
  platform: () => ({
    announcer: createAnnouncer(),
  }),
})

For example, a focused component can announce its label through the platform screen reader:

js
hooks: {
  focus() {
    this.$announcer.speak(this.label)
  },
}

The rendererPlatform setting is separate from platform. It is only passed to the renderer, and should be used for renderer specific platform configuration.

Effects & Shaders ​

SettingTypeDescription
effectsShaderEffect[]Effects for DynamicShader. Removed in Blits v2. Use the shaders setting instead.
shadersShader[]Custom shaders

Inspector & Debugging ​

SettingTypeDescription
inspectorbooleanEnable the inspector tool

Accessibility ​

SettingTypeDescription
announcerbooleanEnable/disable text-to-speech announcer

Example Usage ​

js
Blits.Launch(App, 'app', {
  w: 1920,
  h: 1080,
  debugLevel: 1,
  renderQuality: 'high',
  fonts: [
    { family: 'lato', type: 'msdf', file: 'fonts/Lato-Regular.ttf' },
  ],
  keymap: {
    ArrowLeft: 'left',
    ArrowRight: 'right',
  },
  holdTimeout: 50,
  inputThrottle: 100, // Throttle inputs to 100ms window
  gpuMemory: {
    max: 200,
    target: 0.8,
    cleanupInterval: 5000,
    baseline: 25,
    strict: false,
  },
  inspector: false,
  announcer: true,
  enableMouse: false, // set true for hover + click-to-focus on canvas
  mouseMoveThrottle: 100, // lower (e.g. 16) for hover that tracks the pointer more closely
  platform: (defaults) => ({
    screenHeight: 720,
    input: myInputTarget,
  }),
})