Get started with preact-compat CDN

MIT licensed

Preact-compat is a library that enables using Preact components in React projects.

Tags:
  • preact
  • react
  • compatibility

Stable version

Copied!

How to start using preact-compat 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-compat CDN - cdnhub.io</title>
    <script src="https://cdn.jsdelivr.net/npm/preact/compat/preact.min.js"></script>
    <script src="https://cdn.cdnhub.io/preact-compat/3.19.0/preact-compat.min.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script>
      import { h, Component } from 'preact-compat';

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

      document.addEventListener('DOMContentLoaded', () => {
        const app = document.getElementById('app');
        const instance = ReactDOM.render(<App />, app);
      });
    </script>
  </body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions