What is @vue/runtime-core?
The @vue/runtime-core package is a part of the Vue.js framework that provides the core runtime components necessary for Vue applications to function. It includes the logic for the virtual DOM, components, reactivity system, and other essential features that enable developers to build interactive user interfaces.
What are @vue/runtime-core's main functionalities?
Reactivity System
The reactivity system allows developers to create reactive state objects that automatically update the DOM when the state changes.
{"import { reactive } from '@vue/runtime-core';\nconst state = reactive({ count: 0 });"}
Component Creation
This feature enables developers to define Vue components using the Composition API, which is a function-based approach to creating and managing component state and behavior.
{"import { defineComponent } from '@vue/runtime-core';\nconst MyComponent = defineComponent({\n setup() {\n // Component logic here\n }\n});"}
Custom Renderer API
The Custom Renderer API allows developers to create custom renderers for Vue, enabling the use of Vue's reactivity and component system with different rendering backends, such as canvas or WebGL.
{"import { createRenderer } from '@vue/runtime-core';\nconst { render } = createRenderer({\n patchProp,\n ...otherOptions\n});"}
Other packages similar to @vue/runtime-core
react
React is a popular JavaScript library for building user interfaces. It also has a virtual DOM, component-based architecture, and its own reactivity system. React focuses on a declarative programming model and differs from Vue in syntax and the ecosystem of tools and extensions.
preact
Preact is a fast, 3kB alternative to React with the same modern API. It provides a similar component-based architecture and virtual DOM system but aims to be smaller and faster. Preact is often used for performance-critical applications or when a smaller bundle size is needed.
inferno
Inferno is another React-like library for building high-performance user interfaces. It is heavily optimized for performance and claims to be one of the fastest JavaScript UI libraries available. Inferno shares some similarities with Vue's reactivity and component system but is more focused on performance.
svelte
Svelte is a radical new approach to building user interfaces. Unlike Vue, which updates the DOM in response to state changes, Svelte compiles components to highly optimized imperative code that surgically updates the DOM. This results in faster runtime performance and smaller bundle sizes.
@vue/runtime-core
This package is published only for typing and building custom renderers. It is NOT meant to be used in applications.
For full exposed APIs, see src/index.ts
. You can also run pnpm build runtime-core --types
from repo root, which will generate an API report at temp/runtime-core.api.md
.
Building a Custom Renderer
import { createRenderer } from '@vue/runtime-core'
const { render, createApp } = createRenderer({
patchProp,
insert,
remove,
createElement
})
export { render, createApp }
export * from '@vue/runtime-core'
See @vue/runtime-dom
for how a DOM-targeting renderer is implemented.