Get started with preact CDN

MIT licensed

Preact is a lightweight library for building fast, component-based user interfaces, with a virtual DOM and a similar API to React.

Tags:
  • preact
  • jsx
  • vdom
  • virtual dom
  • components
  • view

Stable version

Copied!

How to start using preact CDN


<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Get started with preact CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/preact/10.19.6/preact.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      import { h, Component } from 'preact';

      class App extends Component {
        render() {
          return (
            <div>
              <h1>Hello, Preact!</h1>
            </div>
          );
        }
      }

      document.addEventListener('DOMContentLoaded', () => {
        const root = document.getElementById('root');
        const app = document.createElement('preact-app');
        app.innerHTML = '<preact-component type="' + App.name + '"></preact-component>';
        root.appendChild(app);
      });
    </script>
  </body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions

1.2.0 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.5.1 1.5.2 10.0.0 10.0.0-alpha.0 10.0.0-alpha.1 10.0.0-alpha.2 10.0.0-alpha.3 10.0.0-alpha.4 10.0.0-beta.0 10.0.0-beta.1 10.0.0-beta.2 10.0.0-beta.3 10.0.0-rc.0 10.0.0-rc.1 10.0.0-rc.2 10.0.0-rc.3 10.0.1 10.0.2 10.0.3 10.0.4 10.0.5 10.1.0 10.1.1 10.10.0 10.10.1 10.10.2 10.10.3 10.10.4 10.10.5 10.10.6 10.11.0 10.11.1 10.11.2 10.11.3 10.12.0 10.12.1 10.13.0 10.13.1 10.13.2 10.14.0 10.14.1 10.15.0 10.15.1 10.16.0 10.17.0 10.17.1 10.18.0 10.18.1 10.18.2 10.19.0 10.19.1 10.19.2 10.19.3 10.19.4 10.19.5 10.19.6 10.19.7 10.2.0 10.2.1 10.20.0 10.20.1 10.20.2 10.21.0 *** 10.22.0 10.3.0 10.3.1 10.3.2 10.3.3 10.3.4 10.4.0 10.4.1 10.4.2 10.4.3 10.4.4 10.4.5 10.4.6 10.4.7 10.4.8 10.5.0 10.5.1 10.5.10 10.5.11 10.5.12 10.5.13 10.5.14 10.5.15 10.5.2 10.5.3 10.5.4 10.5.5 10.5.6 10.5.7 10.5.8 10.5.9 10.6.0 10.6.1 10.6.2 10.6.3 10.6.4 10.6.5 10.6.6 10.7.0 10.7.1 10.7.2 10.7.3 10.8.0 10.8.1 10.8.2 10.9.0 11.0.0-experimental.0 11.0.0-experimental.1 2.0.0 2.0.1 2.1.0 2.2.0 2.3.0 2.4.0 2.4.1 2.5.0 2.5.1 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0 2.8.1 2.8.2 2.8.3 3.0.0 3.0.0-beta1 3.0.0-beta2 3.0.0-beta3 3.0.0-beta4 3.0.1 3.0.2 3.1.0 3.2.0 3.3.0 3.4.0 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.7.0 4.7.1 4.7.2 4.8.0 5.0.0-beta1 5.0.0-beta10 5.0.0-beta11 5.0.0-beta2 5.0.0-beta3 5.0.0-beta4 5.0.0-beta5 5.0.0-beta6 5.0.0-beta7 5.0.0-beta8 5.0.0-beta9 5.0.1-beta.12 5.0.1-beta.14 5.0.1-beta.15 5.1.0-beta.16 5.1.0-beta.17 5.1.0-beta.18 5.1.0-beta.19 5.1.0-beta.20 5.1.0-beta.21 5.1.0-beta.22 5.1.0-beta.23 5.1.0-beta.24 5.1.0-beta.25 5.1.0-beta.26 5.2.0-beta.0 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.6.0 5.7.0 6.0.0 6.0.1 6.0.2 6.1.0 6.2.0 6.2.1 6.3.0 6.4.0 7.0.1 7.0.2 7.0.3 7.1.0 7.2.0 7.2.1 8.0.0 8.0.1 8.1.0 8.2.0 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.2.7 8.2.8 8.2.9 8.3.0 8.3.1 8.4.0 8.4.1 8.4.2 8.5.1 8.5.2 8.5.3