Plain data, explicit render
Nothing to declare or wrap. Change an object or an array, then render.
this.items.push(newItem);
this.render();
Explicit rendering
Solarite is a small library for writing native web components. Write a class, change your data, and
call render(). Solarite updates only the DOM that changed.
Loading the example…
Nothing to declare or wrap. Change an object or an array, then render.
this.items.push(newItem);
this.render();
Explicit rendering
Set an input's value to [object, 'property'] and the two stay in sync.
<input value=${[item, 'name']}>
Two-way binding
A component's <style> applies only to it, and page styles still reach inside.
<style>
:host input { color: navy }
</style>
Scoped styles
A child component's constructor receives the actual object, not a string.
<user-card user=${user}>
constructor({user}) { … }
Child components
data-id elements become properties. Your DOM edits are kept.
<div data-id="chart"></div>
this.chart.append(canvas);
Element references
Objects are never wrapped, so console.log shows your real data.
console.log(this.items);
// [{name: 'Apples'}, …]
How rendering works
They work in plain HTML pages and inside other frameworks.
<my-timer mins="5"></my-timer>
constructor(args={}) {...}
Web components
Type definitions are included. JSX needs a build step; nothing else does.
// tsconfig.json
"jsx": "react-jsx",
"jsxImportSource": "solarite"
JSX
Solarite scores 1.08 in the js-framework-benchmark, where hand-written vanilla JavaScript scores 1.02. This is faster than nearly every other framework.
Minified + Brotli
Runtime dependencies
It renders components. Routing, fetching, and stores are yours to choose, or to skip.
Could be added later if there's demand.
If you change data and don't call render(), the page doesn't update. That's the price of choosing when rendering happens.
Possible API changes before 1.0.
One maintainer, MIT licensed, with a small surface that is easy to read and to fork.
Several years ago I went looking for something simpler than the big JavaScript UI frameworks. I didn't want a build environment or a wait for compilation, and I didn't want to wrap my data in signals before I could use it. What I wanted was class-based components that pass arguments to their children through the constructor, scoped styles and two-way binding without the limits of shadow DOM, and a library I could import anywhere rather than a whole framework. Nothing I found did all of that, so I wrote Solarite.
-- Eric Frost
import h, {Solarite} from 'https://cdn.jsdelivr.net/npm/solarite@0.9.0/dist/Solarite.min.js';The examples in the documentation are live, so you can edit them right in the page.