Overview
Installation
The Wafer package contains both the client and server libraries. To install for use with build tools and/or server usage, use your favourite package manager:
npm install --save @lamplightdev/wafer
You can then import the required base class:
import Wafer from "@lamplightdev/wafer";
class MyExample extends Wafer {}
customElements.define("my-example", MyExample);
or import directly from a CDN to use without a package manager or bundler:
import Wafer from "https://unpkg.com/@lamplightdev/wafer";
Alternatively if you are feeling retro use a <script>
tag:
<script src="https://unpkg.com/@lamplightdev/wafer/dist/wafer.browser.js"></script>
<script>
class MyExample extends Wafer {}
customElements.define("my-example", MyExample);
</script>
On the server Wafer is available as both an ES and a CJS module:
// ES module
import WaferServer from "@lamplightdev/wafer/server/wafer.js";
// or CJS
const WaferServer = require("@lamplightdev/wafer/server/wafer");
class MyExample extends WaferServer {}
Next: Quick guide
Previous: Motivation