preact-render-to-string
Render JSX and Preact components to an HTML string.
Works in Node & the browser, making it useful for universal/isomorphic rendering.
>> Cute Fox-Related Demo (@ CodePen) <<
Render JSX/VDOM to HTML
;;/** @jsx h */ let vdom = <div class="foo">content</div>; let html = ;console;// <div class="foo">content</div>
Render Preact Components to HTML
;;/** @jsx h */ // Classical components work { return <span class="fox"> name </span>; } // ... and so do pure functional components:const Box = <div class=`box box-`> children </div>; let html = ; console;// <div class="box box-open"><span class="fox">Finn</span></div>
Render JSX / Preact / Whatever via Express!
;;;/** @jsx h */ // silly example component:const Fox = <div class="fox"> <h5> name </h5> <p>This page is all about name</p> </div>; // basic HTTP server via express:const app = ;app; // on each request, render and return a component:app;