JynXS: A tiny custom JSX Runtime
JynXS is a lightweight, ~3KB JSX runtime that implements the very basics of a modern UI library without relying on
React.
This project is very experimental and a proof of concept. Not recommended for production use.
Core Features
- Custom JSX runtime implementation
- Supports functional components (only)
- Supports async components, also with a
fallback
. It means you don't need to wrap your components in Suspense
. - Basic hooks implementation:
useState
for state managementuseEffect
for side effects
- Event handling
- Supports
ref
as prop, to access DOM elements - TypeScript support
TO-DO
We won't add support for more complex features like advanced context, portals, style objects, custom hooks, etc.
Getting Started
-
Install the package with any package manager:
pnpm add jynxs
# or
npm install jynxs
# or
bun add jynxs
-
Configure your tsconfig.json
to use the JynXS runtime:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "jynxs"
}
}
-
Configure your Vite project to transpile JSX with esbuild:
import { defineConfig } from 'vite'
export default defineConfig({
esbuild: {
jsxFactory: 'jsx',
jsxFragment: 'Fragment',
},
})
That's it!
Usage Example
An example of how to use the JynXS runtime can be found in src/example.tsx
.
This file demonstrates the usage of functional components, async components, state management, effects, and event
handling.
Building for Production
To create a production build:
pnpm build
Technologies Used
- Vite + esbuild
- Custom JSX Runtime
- TypeScript
No Babel or Webpack needed to transpile the JSX, esbuild is used instead.
License
MIT License