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 🙏

© 2026 – Pkg Stats / Ryan Hefner

can-hyperscript

v0.2.3

Published

Create HyperText with JavaScript and CanJS live binding.

Downloads

38

Readme

can-hyperscript

Build Status

Create HyperText with JavaScript and CanJS live binding.

This is an experimental library and all APIs are subject to change. Feedback is welcome - feel free to open issues with suggestions and feature requests.

What is HyperScript

HyperScript is a way to create HyperText (the HT in HTML) with JavaScript. It looks something like this:

import h from 'hyperscript';

h('div#menu', { style: { 'background-color': 'orange' } },
    h('ul',
        h('li', 'Burger'),
        h('li', 'Hot Dog'),
        h('li', 'French Fries')
    )
);

Use with CanJS Observables

can-hyperscript allows you to use HyperScript with live-binding to CanJS observables.

can-compute

If a compute is passed as an attribute or child node, can-view-live will be used to update the HTML when the value of the compute changes.

import h from 'can-hyperscript';
import compute from 'can-compute';

const message = compute('Hello, World!');
const headerClass = compute('big-h1');
const frag = h('h1', { class: headerClass }, [ message ]);

frag.outerHTML; // <h1 class="big-h1">Hello, World!</h1>

message('Hello, Mars!');
headerClass('bigger-h1');

frag.outerHTML; // <h1 class="bigger-h1">Hello, Mars!</h1>

Map / DefineMap

To use with other CanJS observable types, you can pass a function as an attribute or child node (this example is using arrow functions). These functions will be turned into computes:

import h from 'can-hyperscript';
import DefineMap from 'can-define/map/map';

const data = new DefineMap({
  message: 'World',
  class: 'big-h1'
});
const frag = h('h1', { class: () => data.class }, [ () => `Hello, ${data.message}!` ]);

frag.outerHTML; // <h1 class="big-h1">Hello, World!</h1>

data.class = 'bigger-h1';
data.message = 'Mars';

frag.outerHTML; // <h1 class="bigger-h1">Hello, Mars!</h1>

Use with CanJS Components

can-hyperscript provides a few helpers to make working with can-components simple.

render

can-hyperscript/lib/component provides a render function for rendering the view for a component. This render function will take the Scope of the component, turn it in to an object, and pass it to your view function. You can use properties from the object in your view function using normal bracket or dot-notation.

import h from 'can-hyperscript';
import { render } from 'can-hyperscript/lib/component';
import DefineMap from 'can-define/map/map';
import Component from 'can-component';

const ViewModel = DefineMap.extend({
  message: { value: 'Hello, World!' }
});

const view = data => {
	return h('h1', () => data.message);
};

Component.extend({
  tag: 'my-component',
  ViewModel: ViewModel,
  view: render(view)
});

hyperComponents mixin

There is also a mixin available to allow you to render can-components using hyperscript:

import baseH from 'can-hyperscript';
import { hyperComponents } from 'can-hyperscript/lib/component';

const h = hyperComponents(baseH);

document.body.appendChild(
  h('my-component', {})
);