riot
Riot.js is a tiny, component-based UI library that brings a custom-tag authoring model to the browser, letting you write HTML-centric components with inline scripts, lifecycle hooks, and one-way data flow without a virtual DOM.
MITPermissive — free to use in commercial and proprietary software, with attribution.View license →
Production readiness
5/5- Actively maintainedCommits in the last 6 months
- No known vulnerabilitiesNo OSV advisories
- Clear, usable licenseMIT (permissive)
- Proven adoptionWidely used
- Has documentationDocumentation indexed
npm install riotOur analysis
Riot.js is a minimalist component-based UI library that uses a custom-tag syntax (HTML markup plus an inline default-export script) to define reusable components. It compiles expression bindings ahead of time and uses targeted DOM updates instead of a virtual DOM.
When to use riot
Good for projects that want a lightweight, approachable component model close to standard HTML/JS without the bundle weight or conceptual overhead of larger frameworks. Useful for embedding interactive widgets, small SPAs, or progressively enhancing existing pages, and it ships a modular ecosystem (router, SSR, hydration, CLI, loaders) you can adopt piecemeal.
When not to
If you need a large hiring pool, deep third-party ecosystem, or extensive tooling/integrations, React or Vue are safer bets. For maximal performance with a compiler-first approach, Svelte may be preferable; for thin interactivity layered on server-rendered HTML, Alpine.js is simpler.
Strengths
- Very small gzipped footprint
- Familiar HTML-first component syntax with no new templating language to learn
- Direct DOM bindings avoid virtual-DOM overhead
- Predictable one-way data flow and explicit lifecycle hooks
- Modular ecosystem lets you pull in only what you need
- Plays nicely with other tools since it produces plain DOM
Trade-offs
- Much smaller community and ecosystem than React/Vue/Svelte
- Custom .riot tag files require a compiler/build step for the best experience
- Largely driven by a small core team, creating bus-factor risk
- Fewer ready-made component libraries and integrations
- Less battle-tested for very large, complex applications
Maturity
A long-lived project (14k+ stars, MIT licensed) that is actively maintained, primarily by Gianluca Guarini, with CI, cross-browser testing, and npm/CDN distribution. It is stable and production-usable but occupies a niche position relative to mainstream frameworks.
Simple and elegant component-based UI library
Custom components • Concise syntax • Simple API • Tiny Size
Riot brings custom components to all modern browsers. It is designed to offer you everything you wished the native web components API provided.
Tag definition
<timer>
<p>Seconds Elapsed: { state.time }</p>
<script>
export default {
tick() {
this.update({ time: ++this.state.time })
},
onBeforeMount(props) {
// create the component initial state
this.state = {
time: props.start,
}
this.timer = setInterval(this.tick, 1000)
},
onUnmounted() {
clearInterval(this.timer)
},
}
</script>
</timer>
Mounting
// mount the timer with its initial props
riot.mount('timer', { start: 0 })
Nesting
Custom components let you build complex views with HTML.
<timetable>
<timer start="0"></timer>
<timer start="10"></timer>
<timer start="20"></timer>
</timetable>
HTML syntax is the de facto language on the web and it's designed for building user interfaces. The syntax is explicit, nesting is inherent to the language and attributes offer a clean way to provide options for custom tags.
Performant and predictable
Absolutely the smallest possible amount of DOM updates and reflows.
Fast expressions bindings instead of virtual DOM memory performance issues and drawbacks.
One way data flow: updates and unmounts are propagated downwards from parent to children.
No "magic" or "smart" reactive properties or hooks
Expressions are pre-compiled and cached for high performance.
Lifecycle methods for more control.
Close to standards
No proprietary event system.
Future proof thanks to the javascript module syntax.
The rendered DOM can be freely manipulated with other tools.
No extra HTML root elements,
data-attributes or fancy custom attributes.No new syntax to learn.
Plays well with any frontend framework.
Use your dearest language and tools
Create components with CoffeeScript, Jade, LiveScript, Typescript, ES6 or any pre-processor you want.
Build with @riotjs/cli, webpack, Rollup, parcel, Browserify.
Test however you like; you can load your riot tags directly in node
Powerful and modular ecosystem
The Riot.js ecosystem is completely modular, it's designed to let you pick only the stuff you really need:
@riotjs/cli - CLI to locally compile your tags to javascript
@riotjs/ssr - Super simple server side rendering
@riotjs/hydrate - Hydration strategy for your SPA
@riotjs/route - Isomorphic router
@riotjs/lazy - Lazy components loader
@riotjs/hot-reload - Live reload plugin
@riotjs/compiler - Advanced tags compiler
@riotjs/parser - HTML parser
@riotjs/dom-bindings - Expressions based template engine
@riotjs/custom-elements - native custom elements implementation
CDN hosting
How to contribute
If you are reading this it's already a good sign and I am thankful for it! I try my best working as much as I can on riot but your help is always appreciated.
If you want to contribute to riot helping the project maintenance please check first the list of open issues to understand whether there is a task where you could help.
Riot is mainly developed on UNIX systems so you will be able to run all the commands necessary to build and test the library using our Makefile. If you are on a Microsoft machine it could be harder to set up your development environment properly.
Following the steps below you should be able to properly submit your patch to the project
1) Clone the repo and browse to the riot folder
git clone git@github.com:riot/riot.git && cd riot
2) Set up your git branch
git checkout -b feature/my-awesome-patch
3) Install the npm dependencies
npm i
4) Build and test riot using the Makefile
# To build and test riot
$ make riot
# To build without testing
$ make raw
5) Pull request only against the main branch making sure you have read our pull request template
6) Be patient
Credits
Riot is actively maintained with :heart: by:
Many thanks to all smart people from all over the world who helped improving it.
Official Website
Backers
Support us with a monthly donation and help us continue our activities. Become a backer
Sponsors
Become a sponsor to get your logo on our README. Become a sponsor
Thanks
Special thanks to Browserstack for their support
On this page
- Simple and elegant component-based UI library
- Custom components • Concise syntax • Simple API • Tiny Size
- Tag definition
- Mounting
- Nesting
- Performant and predictable
- Close to standards
- Use your dearest language and tools
- Powerful and modular ecosystem
- CDN hosting
- How to contribute
- 1) Clone the repo and browse to the riot folder
- 2) Set up your git branch
- 3) Install the npm dependencies
- 4) Build and test riot using the Makefile
- 5) Pull request only against the main branch making sure you have read
- 6) Be patient
- Credits
- Official Website
- Backers
- Sponsors
- Thanks