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

@typesugar/react

v0.1.0

Published

🧊 Compile-time React macros β€” Vue/Svelte-style reactivity with automatic dependency tracking

Downloads

60

Readme

@typesugar/react

Compile-time React macros β€” Vue/Svelte-style reactivity for React.

Overview

@typesugar/react brings modern reactivity patterns to React through compile-time macros. Write cleaner component code with automatic dependency tracking β€” no more manual dependency arrays.

Installation

npm install @typesugar/react
# or
pnpm add @typesugar/react

Requires React 18+ as a peer dependency.

Usage

state() β€” Reactive State

import { state } from "@typesugar/react";

function Counter() {
  const count = state(0);

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => count.set(c => c + 1)}>+</button>
    </div>
  );
}

// Compiles to:
// const [__count, __setCount] = useState(0);

derived() β€” Computed Values

import { state, derived } from "@typesugar/react";

function Example() {
  const count = state(0);
  const doubled = derived(() => count * 2);  // Auto-tracks dependencies!

  return <p>Doubled: {doubled}</p>;
}

// Compiles to:
// const doubled = useMemo(() => __count * 2, [__count]);

effect() β€” Side Effects

import { state, effect } from "@typesugar/react";

function DocumentTitle() {
  const title = state("Hello");

  effect(() => {
    document.title = title;  // Auto-extracts dependencies!
  });

  return <input value={title} onChange={e => title.set(e.target.value)} />;
}

// Compiles to:
// useEffect(() => { document.title = __title; }, [__title]);

watch() β€” Explicit Dependencies

import { state, watch } from "@typesugar/react";

function UserProfile() {
  const userId = state(1);
  const profile = state(null);

  watch([userId], async (id) => {
    profile.set(await fetchProfile(id));
  });

  return profile ? <Profile data={profile} /> : <Loading />;
}

component() β€” Embedded Components

import { component, each } from "@typesugar/react";

function TodoList() {
  const todos = state([]);

  // Embedded component β€” auto-hoisted and memoized
  const TodoItem = component<{ todo: Todo }>(({ todo }) => (
    <li>{todo.text}</li>
  ));

  return (
    <ul>
      {each(todos, todo => <TodoItem todo={todo} />, t => t.id)}
    </ul>
  );
}

match() β€” Pattern Matching

import { match } from "@typesugar/react";

type Status =
  | { _tag: "loading" }
  | { _tag: "error"; message: string }
  | { _tag: "success"; data: Data };

function StatusView({ status }: { status: Status }) {
  return match(status, {
    loading: () => <Spinner />,
    error: (e) => <Error message={e.message} />,
    success: (s) => <DataView data={s.data} />,
  });
}

How It Works

The macros transform your code at compile time:

| You Write | It Becomes | | ---------------------- | ------------------------------------ | | state(0) | const [__val, __set] = useState(0) | | derived(() => x * 2) | useMemo(() => x * 2, [x]) | | effect(() => ...) | useEffect(() => ..., [autoDeps]) |

Automatic Dependency Extraction

The transformer analyzes your code to extract dependencies:

const a = state(1);
const b = state(2);
const sum = derived(() => a + b);
// Extracted deps: [a, b]

Compile-Time Checks

  • Purity verification β€” derived() must be a pure function
  • Rules of hooks β€” Violations detected at compile time
  • Exhaustive matching β€” match() ensures all cases handled

Modes

React Mode (default)

Compiles to standard React hooks.

Fine-Grained Mode

Compiles to Solid.js-style signals for true fine-grained reactivity without VDOM diffing.

// Configure in transformer options
{
  plugins: [typesugarPlugin({ reactMode: "fine-grained" })];
}

API Reference

State Management

  • state<T>(initialValue) β€” Create reactive state
  • derived<T>(computation) β€” Create computed value
  • effect(effectFn) β€” Run side effect with auto-deps
  • watch(deps, effectFn) β€” Run effect with explicit deps

Components

  • component<Props>(renderFn) β€” Define embedded component
  • each(items, renderFn, keyFn) β€” Keyed iteration
  • match(value, cases) β€” Pattern matching

Types

  • State<T> β€” Reactive state type
  • Derived<T> β€” Computed value type
  • EmbeddedComponent<P> β€” Component type

License

MIT