Skip to content

Installation

In order to use Van Elements, you will need:

Package manager

sh
$ npm add vanjs-core vanjs-element
sh
$ pnpm add vanjs-core vanjs-element
sh
$ yarn add vanjs-core vanjs-element
sh
$ bun add vanjs-core vanjs-element
ts
import van from "vanjs-core";
import { define } from "vanjs-element";

Browser

Since Van Element doesn't require a build step, it can be loaded from a CDN or stored in a local file (download on jsDelivr).

html
<script src="https://cdn.jsdelivr.net/gh/vanjs-org/van/public/van-latest.nomodule.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanjs-element@latest/dist/van-element.browser.js"></script>
html
<script src="/path/to/vanjs"></script>
<script src="/path/to/van-element"></script>
html
<!-- import maps are now baseline 🎉 -->
<script type="importmap">
  {
    "imports": {
      "vanjs-core": "https://esm.sh/vanjs-core",
      "vanjs-element": "https://esm.sh/vanjs-element"
    }
  }
</script>
<script type="module">
  import van from "vanjs-core";
  import { define } from "vanjs-element";

  ...
</script>

When imported in the global scope, you can use the global object vanE.

javascript
vanE.define(...);

Note:

Since it uses window.customElements, Van Element only works in the browser and should not be used during SSR. Refer to the documentation of your framework to prevent it from defining Van Elements on the server.