Skip to content

dsego/ssr_jsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

⚛️ Server-side JSX for Deno

A simple JSX library for server-side rendering with Deno.

Basic example

/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, renderJSX } from "./mod.js";

const html = await renderJSX(
  <h1>Hello World 😎</h1>,
);

Async components

Supports functional components. Asynchronous components are resolved concurrently.

const Welcome = async function ({ userId }) {
  const user = await findUser(userId);
  return <span>Welcome, {user.name}!</span>;
};

const html = await renderJSX(
  <page>
    <Welcome userId={id} />
  </page>,
);

Partial rendering

Passing a target id will only render the target HTML element.

const partial = await renderJSX(<Page />, { targetElementId: "search-form" });
// <form id="search-form">...</form>
TODO
  • write more tests
  • stream output?
  • typescript?
  • memoize components?

About

A simple JSX library for SSR

Resources

License

Stars

Watchers

Forks

Packages

No packages published