A light weight signal based JavaScript library and framework for building web applications.
Get started now with
npx create-venta-app@latestSee npm create-venta-app for more info on getting started.
Venta provides a familiar React-like API with hooks (useState, useEffect, useMemo, useArray) and JSX, but with fine-grained reactivity for better performance.
import { useState, useArray } from 'venta';
function TodoApp() {
const todos = useArray([]);
const input = useState('');
return (
<div>
<input
value={input.value}
onInput={(e) => input.setValue(e.target.value)}
placeholder="Enter a todo..."
/>
<button onClick={() => {
if (input.value) {
todos.push(input.value);
input.setValue('');
}
}}>Add</button>
{todos.value.length === 0 && <p>No todos yet!</p>}
<ul>
{todos.value.map((todo, i) => (
<li key={i}>
{todo}
<button onClick={() => todos.splice(i, 1)}>Delete</button>
</li>
))}
</ul>
</div>
);
}- React-like API: If you know React hooks, you know Venta
- Displaying state:
{count}in JSX content,value={count.value}in attributes - Reading state: Use
.value(e.g.,if (count.value > 0)) - Updating state: Use
.setValue()(e.g.,count.setValue(5)) - Arrays:
useArray()has reactive methods (push,pop,splice,swap,clear)
| Hook | Usage | Notes |
|---|---|---|
useState(val) |
const x = useState(0)x.setValue(5) |
Read: x.value, Display: {x} |
useArray(arr) |
const xs = useArray([1,2])xs.push(3) |
Methods: push, pop, splice, swap, clear |
useMemo(fn, deps) |
const y = useMemo(() => x.value * 2, [x]) |
Recomputes when deps change |
useEffect(fn, deps) |
useEffect(() => { ... }, [x]) |
Runs on mount & when deps change |
This framework is not polished and should not be used for production applications. I am currently no longer working on this project and it is more of a proof of concept. I hope to eventually come back and polish off this repo.
Venta is fast - like really fast. Checout out these benchmarks from js-framework-benchmark against other popular libraries:
