npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hybrids

v9.1.8

Published

A JavaScript framework for creating fully-featured web applications, components libraries, and single web components with unique declarative and functional architecture

Downloads

8,697

Readme

build status coverage status npm version

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 site.

Quick Look

Component Model

It's based on plain objects and pure functions[^1], still using the Web Components API under the hood:

import { html, define } from "hybrids";
  
function increaseCount(host) {
  host.count += 1;
}

export default define({
  tag: "simple-counter",
  count: 0,
  render: ({ count }) => html`
    <button onclick="${increaseCount}">
      Count: ${count}
    </button>
  `,
});
<simple-counter count="42"></simple-counter>

Open in StackBlitz

You can read more in the Component Model section.

Global State Management

A global state management uses declarative model definitions with support for async external storages, relations, offline caching, and many more:

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`
    <div>
      ${store.pending(user) && `Loading...`}
      ${store.error(user) && `Something went wrong...`}

      ${store.ready(user) && html`
        <p>${user.firstName} ${user.lastName}</p>
      `}
    </div>
  `,
});
<user-details user="2"></user-details>

You can read more in the Store 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.

import { define, html, router } from "hybrids";

import Details from  "./details.js";

const Home = define({
  [router.connect]: { stack: [Details, ...] },
  tag: "app-home",
  render: () => html`
    <template layout="column">
      <h1>Home</h1>
      <nav layout="row gap">
        <a href="${router.url(Details)}">Details</a>
      </nav>
      ...
    </template>  
  `,
});

export define({
  tag: "app-router",
  stack: router(Home),
  render: ({ stack }) => html`
    <template layout="column">
      ${stack}
    </template>
  `,
});
<app-router></app-router>

You can read more in the Router 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:

define({
  tag: "app-home-view",
  render: () => html`
    <template layout="column center gap:2">
      <div layout="grow grid:1|max">
        <h1>Home</h1>
        ...
      </div>

      <footer layout@768px="hidden">...</footer>
    </template>
  `
});

You can read more in the Layout Engine 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!

import { define, html, localize } from "hybrids";

export default define({
  tag: "my-element",
  name: "",
  render: ({ name }) => html`
    <div>Hello ${name}!</div>
  `,
});

localize("pl", {
  "Hello ${0}!": {
    message: "Witaj ${0}!",
  },
});

You can read more in the Localization section of the documentation.

Community

Do you need help? Something went wrong? Feel free to create an issue in the github repository or join the Gitter channel.

License

Hybrids is released under the MIT License.

[^1]: Pure functions only apply to the component definition. Side effects attached to event listeners might mutate the host element.