DEV Community

Cover image for Using Vue’s Custom Renderer API to Build Interfaces Beyond the DOM
Jakub Andrzejewski
Jakub Andrzejewski

Posted on

Using Vue’s Custom Renderer API to Build Interfaces Beyond the DOM

Most Vue developers work exclusively with the traditional browser DOM renderer—but Vue 3’s flexible architecture opens the door to much more. Thanks to the Vue Custom Renderer API, you can build interfaces that run far beyond the DOM, including WebGL scenes, Canvas UIs, terminal apps, game engines, or even native UI trees.

This makes Vue not just a "web framework," but a universal reactive engine capable of driving any rendering target.

In this article, we’ll explore:

• What the Vue Custom Renderer API is and why it matters
• How to create your own custom renderer with createRenderer()
• How TresJS uses a custom renderer to bridge Vue and Three.js

Enjoy!

🤔 What Is the Vue Custom Renderer API?

The Vue Custom Renderer API allows developers to replace Vue’s default DOM renderer with their own rendering logic. Normally, Vue manipulates the DOM by:

• creating HTML elements
• patching attributes
• inserting and removing DOM nodes
• updating text

However, Vue’s rendering system is platform-agnostic.

By implementing a few low-level functions like:

  • createElement
  • patchProp
  • insert
  • remove
  • setElementText

you can instruct Vue to render into any environment, not just the DOM.

Vue still handles the heavy lifting:

  • component lifecycle
  • reactivity
  • diffing and updates
  • scheduling

This separation of concerns allows Vue to power entirely different rendering targets, such as:

• WebGL / Three.js scenes
• Canvas-based UIs
• mobile or native UI trees
• CLI tools and terminal UIs
• PDF or image generation pipelines

Because of this architecture, Vue becomes a universal declarative UI system, not just a browser UI library.

🟢 Building Your Own Vue Custom Renderer

Here’s a minimal example of a custom Vue renderer that outputs a simple in-memory object tree instead of DOM elements.

import { createRenderer } from 'vue'

const renderer = createRenderer({
  createElement(type) {
    return { type, props: {}, children: [] }
  },

  insert(child, parent) {
    parent.children.push(child)
  },

  patchProp(el, key, _prev, next) {
    el.props[key] = next
  },

  setElementText(el, text) {
    el.text = text
  },

  remove(el, parent) {
    parent.children = parent.children.filter(c => c !== el)
  }
})

export const createApp = (...args) => renderer.createApp(...args)
Enter fullscreen mode Exit fullscreen mode

This renderer could serve as the foundation for:

  • a PDF rendering AST
  • a 2D game engine scene tree
  • terminal UI components
  • a robotics control interface
  • a design tool or canvas-based editor

Vue manages the reactivity and component model, while your renderer defines how nodes are created, updated, and removed.

This combination is extremely powerful — and heavily underused.

🟢 TresJS Uses the Vue Renderer API to Control Three.js

One of the most popular real-world implementations of the Vue 3 Custom Renderer API is TresJS.

TresJS allows developers to use Vue components to describe Three.js 3D scenes:

<TresCanvas>
  <TresMesh :rotation="rotation">
    <TresBoxGeometry />
    <TresMeshStandardMaterial color="skyblue" />
  </TresMesh>
</TresCanvas>
Enter fullscreen mode Exit fullscreen mode

Instead of building DOM nodes, the TresJS renderer:

Vue Operation TresJS Implementation
createElement Creates a Three.js Mesh, Geometry, Material objects
insert Adds objects to the scene graph
patchProp Updates rotation, position, materials, colors, etc.
remove Removes objects and disposes WebGL resources

This makes Vue a declarative UI layer for 3D scenes, enabling features like:

  • reactive animation
  • composable 3D components
  • component-driven scene structure
  • full SSR-friendly integration

TresJS allows you to write Vue components that control Three.js objects:

<TresCanvas>
  <TresMesh :rotation="rotation">
    <TresBoxGeometry />
    <TresMeshStandardMaterial color="skyblue" />
  </TresMesh>
</TresCanvas>
Enter fullscreen mode Exit fullscreen mode

TresJS implements a renderer where:

Vue Operation TresJS Implementation
createElement Creates a Three.js Mesh, Geometry, Material…
insert Adds an object to the Three.js scene graph
patchProp Updates position, rotation, color, materials…
remove Disposes GPU resources and removes objects

This lets developers build 3D scenes declaratively using Vue components—something impossible without the Custom Renderer API.

🟢 When Should You Use a Custom Renderer?

A custom Vue renderer is ideal when:

• Your output is not the DOM
• The target has a hierarchical structure (scene graph, nodes, layers)
• You want Vue’s reactivity to drive complex state
• A declarative UI layer simplifies your architecture

Common use cases include:

  • WebGL / 3D engines (TresJS, custom Three.js UIs)
  • Canvas rendering (2D games, graphics tools)
  • Native interfaces (custom host platforms, IoT devices)
  • Terminal UI tools (TUI frameworks powered by Vue)
  • PDF or image generators
  • Robotics dashboards or control systems

If your platform involves nodes, properties, and updates — Vue can probably render it.

📖 Learn more

If you would like to learn more about Vue, Nuxt, JavaScript or other useful technologies, checkout VueSchool by clicking this link or by clicking the image below:

Vue School Link

It covers the most important concepts while building modern Vue or Nuxt applications that can help you in your daily work or side projects.

🧪 Advance skills

A certification boosts your skills, builds credibility, and opens doors to new opportunities. Whether you're advancing your career or switching paths, it's a smart step toward success.

Check out Certificates.dev by clicking this link or by clicking the image below:

Certificates.dev Link

Invest in yourself—get certified in Vue.js, JavaScript, Nuxt, Angular, React, and more!

✅ Summary

Vue’s Custom Renderer API transforms Vue from a DOM framework into a reactive universal UI engine. Whether you're building 3D environments, terminal UIs, or custom rendering engines, Vue provides the power and flexibility you need.

Take care!
And happy coding as always 🖥️

Top comments (0)