Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erikyo/xjsx


https://github.com/erikyo/xjsx

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# X-jsx - A library for rendering JSX to the DOM with reactivity, the first to be weighted in bytes

X-jsx is a lightweight library for rendering JSX to the DOM with reactivity support. It provides a minimalistic approach to building reactive user interfaces with JSX syntax.

![jsx](https://github.com/erikyo/xjsx/assets/8550908/896efa3c-92ed-4e8c-9a5e-01de98d5aead)

## Features

- **JSX Compilation**: Compile JSX syntax to DOM elements, allowing for intuitive UI development.
- **Reactivity**: Support for state management and effects, enabling reactive updates to the UI.
- **Lightweight**: Small footprint with a size of only 864 bytes, making it ideal for projects where code size is a concern.

## Installation

To install xjsx, you can use npm or yarn:

```sh
npm install x-jsx
```

## Usage

Here's a simple example of how to use xjsx in your project:

```typescript jsx
import { useState, useEffect } from 'xjsx';

const Counter = () => {
const [count, setCount] = useState(0);

useEffect(() => console.log('=>', count()));

return (


Count: {count}


setCount((c) => c + 1)}>Increment

);
};

const App = () => (



I'm from JSX





);

// Rendering
document.getElementById('root')?.appendChild();
```

## API

### `createElement`

Creates a virtual DOM element.

### `render`

Renders a virtual DOM element to a real DOM element.

### `useState`

A hook for managing state in functional components.

### `useEffect`

A hook for handling side effects in functional components.

## Contributing

Contributions are welcome! Feel free to submit bug reports, feature requests, or pull requests on the [GitHub repository](https://github.com/your-username/xjsx).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

### Bundlers settings

Vite configuration

```json
export default defineConfig({
esbuild: {
jsx: 'automatic',
jsxImportSource: 'xjsx'
}
})
```