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

@arcmantle/lit-jsx

v1.1.15

Published

A JSX runtime and compiler that transforms JSX into Lit templates.

Downloads

1,456

Readme

lit-jsx

A powerful JSX compiler and Vite plugin that transforms JSX into native Lit templates at compile time with zero runtime overhead.

📖 View Full Documentation | 🚀 Getting Started | 📦 Installation

🚀 Features

lit-jsx brings the familiar JSX syntax to the Lit ecosystem while maintaining the performance and capabilities that make Lit exceptional.

// Write familiar JSX
function TodoItem({ todo, onToggle, onDelete }) {
  return (
    <div classList={{ completed: todo.completed }}>
      <input
        type="checkbox"
        checked={as.prop(todo.completed)}
        disabled={as.bool(todo.readonly)}
        onchange={() => onToggle(todo.id)}
      />
      <span>{todo.text}</span>
      <button onclick={() => onDelete(todo.id)}>Delete</button>
    </div>
  );
}

// Compiles to efficient Lit templates
html`
  <div class=${classMap({ completed: todo.completed })}>
    <input
      type="checkbox"
      .checked=${todo.completed}
      ?disabled=${todo.readonly}
      @change=${() => onToggle(todo.id)}
    />
    <span>${todo.text}</span>
    <button @click=${() => onDelete(todo.id)}>Delete</button>
  </div>
`

✨ Key Benefits

  • ⚡ Zero Runtime Overhead: Pure compile-time transformation to native Lit templates
  • 🎯 Type-Safe: Comprehensive TypeScript support with native DOM type mappings for accurate IntelliSense and type checking
  • 🔧 Vite Integration: Seamless setup with the included Vite plugin
  • 🎨 Lit Ecosystem: Works with all Lit directives, custom elements, and patterns
  • 🎛️ Flexible Binding: Fine-grained control over attribute, property, and boolean bindings
  • 🏷️ Dynamic Tags: Support for conditional element types with static template optimization
  • 📦 Function Components: Full support for composable function components
  • 🔗 Custom Elements: Use LitElement classes directly in JSX with automatic generic type support
  • 🧩 Library Components: Built-in For, Show, and Choose components for common rendering patterns

📦 Installation

npm install @arcmantle/lit-jsx lit-html
# or
pnpm add @arcmantle/lit-jsx lit-html
# or
yarn add @arcmantle/lit-jsx lit-html

⚡ Quick Start

For complete setup instructions, see the Installation Guide and Getting Started Guide.

1. Configure Vite

// vite.config.ts
import { litJsx } from '@arcmantle/lit-jsx/vite-jsx-preserve';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    litJsx({
      legacyDecorators: true
    })
  ],
});

2. Configure TypeScript

{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "@arcmantle/lit-jsx"
  }
}

3. Start Writing JSX

import { LitElement } from 'lit';
import { For, Show, Choose } from '@arcmantle/lit-jsx';

export class MyComponent extends LitElement {
  render() {
    return (
      <div>
        <h1>Hello lit-jsx!</h1>
        <p>JSX compiled to Lit templates with utility components</p>

        <Show when={this.items.length > 0}>
          {(length) => (
            <For each={this.items}>
              {(item, index) => <div>{item}</div>}
            </For>
          )}
        </Show>
      </div>
    );
  }
}

🎯 Core Concepts

For complete documentation, visit the full documentation site.

Custom Element Identification

  • Tag names (like <counter-element>) work directly without special attributes
  • Classes (like <Counter />) require the static attribute
  • Optional: Enable useImportDiscovery: true for automatic detection

Learn more →

Attribute Binding Control

  • Default: Attribute binding (value={x})
  • as.prop(): Property binding (.property=${x})
  • as.bool(): Boolean attribute binding (?disabled=${x})

Learn more →

Special Attributes

  • classList / class={{...}}: Conditional classes with classMap
  • styleList / style={{...}}: Dynamic styles with styleMap
  • onclick, onchange, etc.: Event handlers
  • ref: Element references
  • directive: Apply Lit directives
  • {...props}: Spread attributes

Full syntax guide →

🏗️ Component Patterns

Function Components

Stateless components that receive props and return JSX. Support TypeScript, generics, children, and all JSX features.

Learn more →

Custom Elements

Use LitElement classes directly in JSX with full type safety and generic support. Classes require the static attribute.

Learn more →

Dynamic Tags

Use as.tag() for conditional element types with optimized static templates.

Component guide →

Library Components

Built-in components for common patterns:

  • <For>: List rendering with keys and separators
  • <Show>: Conditional rendering with optional fallback
  • <Choose>: Switch-like multi-condition rendering

🔧 Advanced Usage

For comprehensive guides, examples, and best practices, see the full documentation.

  • Lit Directives: Use all Lit directives (when, repeat, guard, etc.)
  • Performance: Optimization tips and compiled templates
  • TypeScript: Advanced typing patterns

View advanced guides →

🎛️ Configuration

Plugin options:

  • legacyDecorators: Enable legacy decorator support
  • useCompiledTemplates: Compile-time template optimization (default: true)
  • useImportDiscovery: Auto-detect custom elements (default: false)

Full configuration guide →

🔗 Ecosystem & Migration

Full compatibility with:

  • LitElement and reactive properties
  • All Lit directives
  • Web Components standards
  • TypeScript with native DOM types

Migrating from React or Lit templates? See the migration guide.

🤝 Contributing

Contributions, issues or requests are welcome!

📄 License

Apache-2.0

...