Package Exports
- @jasonshimmy/custom-elements-runtime
Readme
๐งฉ Custom Elements Runtime
Ultra-powerful, type-safe runtime for fast, reactive, and maintainable web components.
Build modern components with strict TypeScript, zero dependencies, and a clean functional API. Designed for speed, standards compliance, and productivity.
๐น๏ธ Try it on Codepen.io.
โจ Why You'll Love It
- โก Blazing Fast: Minimal runtime, instant updates, zero dependencies.
- ๐จ JIT CSS: On-demand, utility-first styling directly in your HTML at runtime.
- ๐ช No Build Necessary: Instant development feedback, no bundling required.
- ๐งโ๐ป TypeScript First: Strict types, intellisense, and safety everywhere.
- ๐งฉ Functional API: No classes, no boilerplateโjust pure functions.
- ๐ ๏ธ SSR & HMR Ready: Universal rendering and instant hot reloads.
- ๐ Extensible: Directives, event bus, store, and more for advanced use cases.
- ๐ Developer Friendly: Clean docs, examples, and a welcoming community.
โฑ๏ธ Getting Started
- Install:
npm install @jasonshimmy/custom-elements-runtime - Create a Component:
import { component, ref, html, useEmit } from '@jasonshimmy/custom-elements-runtime';
component('my-counter', ({ initialCount = 0 }) => {
const count = ref(initialCount);
const emit = useEmit();
const handleClick = () => {
count.value++;
emit('update:initial-count', { count: count.value });
};
return html`
<button
type="button"
class="px-4 py-2 bg-blue-500 text-white rounded"
@click.prevent="${handleClick}"
>
Count: ${count.value}
</button>
`;
});- Use in HTML:
<my-counter
initial-count="5"
@update:initial-count="handleCountUpdate"
></my-counter>
<script>
function handleCountUpdate(event) {
console.log('Count updated to:', event.detail.count);
}
</script>- Enjoy instant reactivity and type safety!
๐ Documentation Index
Explore the complete documentation for every runtime feature:
๐ Getting Started
- ๐ฏ Functional API - Start here! Complete guide to the modern functional component API
๐๏ธ Core Features
- ๐งฉ Template - Template syntax and html function
- ๐งญ Directives - Conditional rendering with
when,each, andmatch - ๐ ๏ธ Directive Enhancements - Advanced directive utilities (
unless,whenEmpty, etc.) - ๐ Bindings - Data binding with
:prop,@event,:model,:class,:style - ๐ Events Deep Dive - Custom event emission and handling patterns
๐จ Styling
- ๐จ JIT CSS - On-demand utility-first styling system
๐ Communication & State
- ๐ข Event Bus - Global event system for cross-component communication
- ๐๏ธ Store - Global state management
- ๐ฆ Router - Client-side routing
- ๐ค Cross-Component Communication - Patterns for component interaction
โก Advanced Features
- ๐ฎ Virtual DOM - VDOM implementation and performance details
- ๐ SSR - Server-side rendering support
- โป๏ธ HMR - Hot module replacement
- ๐ก๏ธ Infinite Loop Protection - Runtime safeguards against infinite loops
- ๐ Secure Expression Evaluator - Safe evaluation of dynamic expressions in templates
๐ง Integration Guides
- โ๏ธ React Integration - Using components in React apps
- ๐ฆ Vue Integration - Using components in Vue apps
- ๐ ฐ๏ธ Angular Integration - Using components in Angular apps
- ๐ฅ Svelte Integration - Using components in Svelte apps
๐ ๏ธ Troubleshooting
- ๐ง Troubleshooting - Common issues and solutions
For examples and implementation details, explore the source code in src/lib/.
๐งโ๐ฌ Real-World Examples
๐ Showcase & Community
- Showcase your components! Open a PR to add your project to our gallery.
- Questions or ideas? Start a discussion or open an issue.
- Contribute: We welcome PRs for docs, features, and examples.
- โค๏ธ Like what you see? Support ongoing development on Patreon
๐ Support This Project
Custom Elements Runtime is a labor of love built to make modern web development faster and more expressive. If it's helping you build better components, consider supporting me on Patreon to help keep the momentum going.
Your support helps fund continued development, documentation, and community engagement. Every bit helpsโthank you!