Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hybridsjs/hybrids
Extraordinary JavaScript UI framework with unique declarative and functional architecture
https://github.com/hybridsjs/hybrids
framework localization router state-management webcomponents
Last synced: 5 days ago
JSON representation
Extraordinary JavaScript UI framework with unique declarative and functional architecture
- Host: GitHub
- URL: https://github.com/hybridsjs/hybrids
- Owner: hybridsjs
- License: mit
- Created: 2016-12-06T20:19:43.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-01-08T11:37:25.000Z (17 days ago)
- Last Synced: 2025-01-12T19:05:29.293Z (13 days ago)
- Topics: framework, localization, router, state-management, webcomponents
- Language: JavaScript
- Homepage: https://hybrids.js.org
- Size: 4.03 MB
- Stars: 3,066
- Watchers: 45
- Forks: 88
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-lit - hybrids - UI library for creating Web Components with simple and functional API. (Similar libraries / Other Tools)
- awesome-web-components - hybrids - UI library for creating Web Components with simple and functional API. (Libraries / Functional)
- awesome-starred - hybridsjs/hybrids - Extraordinary JavaScript UI framework with unique declarative and functional architecture (framework)
README
[![build status](https://github.com/hybridsjs/hybrids/actions/workflows/test.yml/badge.svg)](https://github.com/hybridsjs/hybrids/actions/workflows/test.yml?query=branch%3Amain)
[![coverage status](https://coveralls.io/repos/github/hybridsjs/hybrids/badge.svg?branch=main)](https://coveralls.io/github/hybridsjs/hybrids?branch=main)
[![npm version](https://img.shields.io/npm/v/hybrids.svg?style=flat)](https://www.npmjs.com/package/hybrids)> An extraordinary JavaScript framework for creating client-side web applications, UI components libraries, or single web components with unique mixed declarative and functional architecture
**Hybrids** provides a complete set of features for building modern web applications:
* **Component Model** based on plain objects and pure functions
* **Global State Management** with external storages, offline caching, relations, and more
* **App-like Routing** based on the graph structure of views
* **Layout Engine** making UI layouts development much faster
* **Localization** with automatic translation of the templates content
* **Hot Module Replacement** support without any additional configuration### Documentation
The project documentation is available at the [hybrids.js.org](https://hybrids.js.org) site.
## Quick Look
### Component Model
It's based on plain objects and pure functions[^1], still using the [Web Components API](https://developer.mozilla.org/en-US/docs/Web/Web_Components) under the hood:
```javascript
import { html, define } from "hybrids";
function increaseCount(host) {
host.count += 1;
}export default define({
tag: "simple-counter",
count: 0,
render: ({ count }) => html`
Count: ${count}
`,
});
``````html
```
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/hybrids-simple-counter)
You can read more in the [Component Model](https://hybrids.js.org/#/component-model/definition.md) section.
### Global State Management
A global state management uses declarative model definitions with support for async external storages, relations, offline caching, and many more:
```javascript
import { define, store, html } from "hybrids";const User = {
id: true,
firstName: "",
lastName: "",
[store.connect] : {
get: id => fetch(`/users/${id}`).then(...),
},
};define({
tag: "user-details",
user: store(User),
render: ({ user }) => html`
${store.pending(user) && `Loading...`}
${store.error(user) && `Something went wrong...`}${store.ready(user) && html`
${user.firstName} ${user.lastName}
`}
`,
});
``````html
```
You can read more in the [Store](https://hybrids.js.org/#/store/usage.md) section.
### App-like Routing
Rather than just matching URLs with the corresponding components, the router depends on a tree-like structure of views, which have their own routing configuration. It makes the URLs optional, have out-the-box support for dialogs, protected views, and many more.
```javascript
import { define, html, router } from "hybrids";import Details from "./details.js";
const Home = define({
[router.connect]: { stack: [Details, ...] },
tag: "app-home",
render: () => html`
Home
Details
...
`,
});export define({
tag: "app-router",
stack: router(Home),
render: ({ stack }) => html`
${stack}
`,
});
``````html
```
You can read more in the [Router](https://hybrids.js.org/#/router/usage.md) section.
### Layout Engine
Create CSS layouts in-place in templates, even without using Shadow DOM, but still keeping the encapsulation of the component's styles:
```javascript
define({
tag: "app-home-view",
render: () => html`
Home
...
...
`
});
```You can read more in the [Layout Engine](https://hybrids.js.org/#/component-model/layout-engine.md) section of the documentation.
### Localization
The library supports automatic translation of the component's content, which makes translation seamless and easy to integrate. Additionally, it provides a way to add dynamic messages with plural forms, HTML content, or use messages outside of the template context. Also, it comes with handy CLI tool to extract messages from the source code!
```javascript
import { define, html, localize } from "hybrids";export default define({
tag: "my-element",
name: "",
render: ({ name }) => html`
Hello ${name}!
`,
});localize("pl", {
"Hello ${0}!": {
message: "Witaj ${0}!",
},
});
```You can read more in the [Localization](https://hybrids.js.org/#/component-model/localization.md) section of the documentation.
## Community
Do you need help? Something went wrong? Feel free to create [an issue](https://github.com/hybridsjs/hybrids/issues/new) in the github repository or join the [Gitter](https://gitter.im/hybridsjs/hybrids) channel.
## License
**Hybrids** is released under the [MIT License](LICENSE).
[^1]: Pure functions only apply to the component definition. Side effects attached to event listeners might mutate the host element.