-
Notifications
You must be signed in to change notification settings - Fork 10
Using can ssr
Matthew Phillips edited this page Nov 20, 2015
·
8 revisions
can-ssr is able to handle server-side rendering of your application by loading it in a custom module loader based on StealJS. In order to work can-ssr expects a couple of functions to be implemented by your application's main (defined in your package.json). These functions look like (note that the examples are in ES6, but all formats are supported):
import initApp from './init';
export function createState(request) {
return {
page: request.url.split("/").pop()
}
}
export function render(document, state) {
let title = document.createElement("title");
title.appendChild(document.createTextNode("Hello world"));
document.head.appendChild(title);
document.body.appendChild(initApp(state));
}