Skip to main content
Module

x/fastro/examples/ssr.ts

The Web Framework for Full Stack Apps
Go to Latest
File
import fastro, { Context, HttpRequest } from "../mod.ts";import user from "../pages/user.tsx";
const f = new fastro();
// simulate async methodconst getUser = (data: string) => Promise.resolve(data);
// init page with the handlerf.page( "/", user, async (_req: HttpRequest, ctx: Context) => { // get data from async method const data = await getUser("Guest");
const options = { // pass data to component via props props: { data }, status: 200, html: { head: { title: "React Component" } }, };
// render react component from server return ctx.render(options); },);
await f.serve();