A .mjs bundle of preact, htm and preact hooks.
npm install @web-mjs/preactimport 'https://unpkg.com/@web-mjs/preact'js
import { render, html, useState, useEffect } from 'https://unpkg.com/@web-mjs/preact';
const App = () => {
const [clicks, setClicks] = useState(0);
useEffect(() => {
document.title = "Clicks: " + clicks;
});
return html;
};
`
The module bundles preact, preact/hooks, html template and preact-custom-element. The full list of exported members:
* h, html, render
* createElement, cloneElement, isValidElement
* Fragment, Component, createContext, hydrate, options
* hooks: useReducer, useState, useEffect, useLayoutEffect, useRef, useCallback, useContext, useDebugValue, useErrorBoundary
Web Components
The registerCustomElement function from preact is exported as:
`js
import { webComponents } from 'https://unpkg.com/@web-mjs/preact';
webComponents.register(SomeComponent, 'x-some-tag');
`
🚧 web-mjs is not affiliated with the Preact team. To build on your own, use rollup or npm run build`