Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

mary-ext/pkg-jsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsx

Serialize JSX to string, fully type-safe.

Usage

/** @jsxImportSource jsr:@mary/jsx */

import type { JSXNode } from 'jsr:@mary/jsx';

const Card = ({ title, children }: { title: string; children: JSXNode }) => {
	return (
		<div class='card'>
			<div class='card__title'>{title}</div>
			<div class='card__body'>{children}</div>
		</div>
	);
};

const App = () => {
	return (
		<>
			<h1>Hello!</h1>
			<Card title='Card title'>
				<p>We're inside a card!</p>
			</Card>
		</>
	);
};

const result = <App />;

result.value;

JSX templates are eagerly interpreted.

Precompiled JSX templates

This library supports Deno's precompiled JSX transformation for even faster serialization, you can make use of it by adding the following configuration to your deno.json file:

{
	"compilerOptions": {
		"jsx": "precompile",
		"jsxImportSource": "jsr:@mary/jsx"
	}
}

About

Serialize JSX to string, fully type-safe

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published