Introduction

REALM is a small runtime for building native web components in HTML. A component is a single <custom-element> tag that holds three things: a <script> with plain JavaScript, a <style>, and markup. REALM turns it into a custom element with a shadow root. There is no compiler, no virtual DOM and no build step.

index.htmlhello-card.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Introduction demo</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/realm.css">
  <script type="module" src="https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/realm.js"></script>
</head>
<body>
  <import-element from="./hello-card.html"></import-element>

  <hello-card name="Ana"></hello-card>
</body>
</html>
<custom-element name="hello-card">
  <script>
    const props = defineProps({ name: prop.string().default("world") });
    const greeting = useState({ count: 0 });

    function wave() {
      greeting.count++;
    }
  </script>

  <style>
    :host {
      display: block;
    }
  </style>

  <p>Hello, <slot name="@name"></slot>!</p>
  <button onclick="wave()">Waved <slot name="#greeting.count"></slot> times</button>
</custom-element>

Hello, !

In this example:

Why REALM

What REALM is not

Where to go next

Edit this page on GitHub · View as Markdown