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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@twiqjs/twiq

v0.3.0

Published

A tiny, zero-build, type-safe UI library for modern web development.

Readme

twiq

English | Japanese

twiq is a tiny, zero-build, type-safe UI library for modern web development. It allows you to build declarative interfaces using standard HTML/SVG tags without the overhead of a Virtual DOM or complex build steps.

Features

  • 🪶 Tiny: Minimal footprint, zero dependencies.
  • Zero Build: Works directly in the browser (standard ES modules).
  • 🛡️ Type-Safe: Full TypeScript support for HTML and SVG tags.
  • Declarative: Describe your UI as a pure function of state.
  • 🧩 No VDOM: Direct DOM manipulation for maximum performance.

Installation

npm install @twiqjs/twiq

Or use it directly via CDN in your HTML (ES Modules):

<script type="module">
  import { tags, mount } from 'https://unpkg.com/@twiqjs/twiq/dist/twiq.js';
</script>

Usage

Basic Example

import { tags, mount } from '@twiqjs/twiq';

const { div, h1, button } = tags;

// 1. Define a component
// Components are just functions that return elements.
const App = (count) => 
  div({ id: 'app' },
    h1({}, `Count: ${count}`),
    button({ 
      onClick: () => update(count + 1) 
    }, 'Increment')
  );

// 2. Define update function
const update = (newCount) => {
  mount('app', App(newCount));
};

// 3. Initial mount
// You need a container in your HTML: <div id="app"></div>
mount('app', App(0));

How It Works

mount is a simple helper that updates the content of a target element.

  1. Target Resolution: It finds the target element by ID (or accepts an Element directly).
  2. Content Replacement: It uses replaceChildren to replace the target's content with the new elements.

[!NOTE] twiq does not use a Virtual DOM. mount replaces the children of the target element directly.

Functional Components

Components are just functions that return elements.

const { li, span } = tags;

const TodoItem = (task) => 
  li({ class: task.completed ? 'done' : '' },
    span({}, task.title)
  );

// Usage in a list
// Note: You must use spread syntax (...) for arrays.
const TaskList = (tasks) => 
  div({}, 
    ...tasks.map(TodoItem)
  );

Event Handling

Props starting with on are treated as event listeners.

button({ onClick: (e) => console.log('Clicked!') }, 'Click Me')

Styling

Use standard class attributes or style strings.

div({ class: 'container', style: 'color: red; padding: 10px;' }, 'Content')

API Reference

tags / tagsSvg

Proxies that generate functions for standard HTML and SVG elements.

const { div, span } = tags;
const { svg, circle } = tagsSvg;

// syntax: tag(props?, ...children)
div({ id: 'foo' }, 'Hello');
  • props: Object key-values for attributes. on[Event] keys attach listeners. Functions passed as values are invoked.
  • children: Strings or Nodes. Arrays are not accepted directly; use spread syntax (...).

mount(target, ...children)

Updates the content of a target element.

  • target: string (ID) or Element.
  • children: string or Node. Multiple arguments can be passed.
  • Behavior: Uses replaceChildren to update the target. Arrays must be spread (...).

License

MIT