Package Exports
- @jasonshimmy/custom-elements-runtime
Readme
๐งฉ Custom Elements Runtime
The Complete Web Components Framework
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, useProps } from '@jasonshimmy/custom-elements-runtime';
component('my-counter', () => {
const props = useProps({ initialCount: 0 });
const count = ref(props.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-primary-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!
๐ฆ Complete API Reference
Core API
import {
// Component Creation
component,
// Template & Styling
html,
css,
// Reactive State
ref,
computed,
watch,
// Hooks
useProps,
useEmit,
useOnConnected,
useOnDisconnected,
useOnAttributeChanged,
useOnError,
useStyle,
// Directives
when,
each,
match,
anchorBlock,
// Directive Enhancements
unless,
whenEmpty,
whenNotEmpty,
eachWhere,
switchOnLength,
eachGroup,
eachPage,
switchOnPromise,
whenMedia,
responsive,
mediaVariants,
responsiveOrder,
// Transitions
Transition,
TransitionGroup,
transitionPresets,
createTransitionPreset,
getTransitionStyleSheet,
// Event Bus
eventBus,
emit, // Shorthand for eventBus.emit
on, // Shorthand for eventBus.on
off, // Shorthand for eventBus.off
once, // Shorthand for eventBus.once
listen, // DOM event listener wrapper
// Store
createStore,
// Router
useRouter,
initRouter,
matchRoute,
matchRouteSSR,
parseQuery,
// SSR & Types
renderToString,
VNode,
} from '@jasonshimmy/custom-elements-runtime';๐ 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- Inverse ofwhenwhenEmpty/whenNotEmpty- Collection checkseachWhere- Filtered iterationswitchOnLength- Render based on array lengtheachGroup- Group and render itemseachPage- Pagination supportswitchOnPromise- Async state renderingwhenMedia- Media query responsive renderingresponsive- Responsive utilities
- ๐ Bindings - Data binding with
:prop,@event,:model,:class,:style - ๐ Events Deep Dive - Custom event emission and handling patterns
- ๐ฌ Transitions Guide - Animation and transition effects
๐จ 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!