Server Rendering

Introduction

The API for server components is the same as the client API detailed above, so that the same component definitions can be used on both the server and client.

A server component extends the WaferServer class:

import WaferServer from "@lamplightdev/wafer/lib/server/wafer.js";

class MyExample extends WaferServer {
static get template() {
return '<div id="firstname"></div>';
}

static get props() {
return {
firstname: {
type: String,
targets: [
{
selector: "$#firstname",
text: true,
},
],
},
};
}
}

Components can be then rendered on the server by either:

Components can be either:

Next: Parsing Previous: Helpers