@jasonshimmy/custom-elements-runtime
Version:
A powerful, modern, and lightweight runtime for creating reactive web components with TypeScript
123 lines (94 loc) โข 5.6 kB
Markdown
# ๐งฉ Custom Elements Runtime
[](https://patreon.com/jshimkoski)
> **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](https://codepen.io/jshimkoski/pen/JoYmpxm).
## โจ 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
1. **Install:** `npm install @jasonshimmy/custom-elements-runtime`
2. **Create a Component:**
```ts
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-primary-500 text-white rounded"
@click.prevent="${handleClick}"
>
Count: ${count.value}
</button>
`;
});
```
3. **Use in HTML:**
```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>
```
4. **Enjoy instant reactivity and type safety!**
## ๐ Documentation Index
Explore the complete documentation for every runtime feature:
### ๐ **Getting Started**
- [**๐ฏ Functional API**](./docs/functional-api.md) - **Start here!** Complete guide to the modern functional component API
### ๐๏ธ **Core Features**
- [๐งฉ Template](./docs/template.md) - Template syntax and html function
- [๐งญ Directives](./docs/directives.md) - Conditional rendering with `when`, `each`, and `match`
- [๐ ๏ธ Directive Enhancements](./docs/directive-enhancements.md) - Advanced directive utilities (`unless`, `whenEmpty`, etc.)
- [๐ Bindings](./docs/bindings.md) - Data binding with `:prop`, `@event`, `:model`, `:class`, `:style`
- [๐ Events Deep Dive](./docs/events-deep-dive.md) - Custom event emission and handling patterns
### ๐จ **Styling**
- [๐จ JIT CSS](./docs/jit-css.md) - On-demand utility-first styling system
### ๐ **Communication & State**
- [๐ข Event Bus](./docs/event-bus.md) - Global event system for cross-component communication
- [๐๏ธ Store](./docs/store.md) - Global state management
- [๐ฆ Router](./docs/router.md) - Client-side routing
- [๐ค Cross-Component Communication](./docs/cross-component-communication.md) - Patterns for component interaction
### โก **Advanced Features**
- [๐ฎ Virtual DOM](./docs/virtual-dom.md) - VDOM implementation and performance details
- [๐ SSR](./docs/ssr.md) - Server-side rendering support
- [โป๏ธ HMR](./docs/hmr.md) - Hot module replacement
- [๐ก๏ธ Infinite Loop Protection](./docs/infinite-loop-protection.md) - Runtime safeguards against infinite loops
- [๐ Secure Expression Evaluator](./docs/secure-expression-evaluator.md) - Safe evaluation of dynamic expressions in templates
### ๐ง **Integration Guides**
- [โ๏ธ React Integration](./docs/react-integration.md) - Using components in React apps
- [๐ฆ Vue Integration](./docs/vue-integration.md) - Using components in Vue apps
- [๐
ฐ๏ธ Angular Integration](./docs/angular-integration.md) - Using components in Angular apps
- [๐ฅ Svelte Integration](./docs/svelte-integration.md) - Using components in Svelte apps
### ๐ ๏ธ **Troubleshooting**
- [๐ง Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
For examples and implementation details, explore the source code in `src/lib/`.
## ๐งโ๐ฌ Real-World Examples
- [Form Input & Validation](./src/components/examples/FormInputValidation.ts)
- [Minimal Example](./src/components/examples/MinimalExample.ts)
- [Shopping Cart](./src/components/examples/ShoppingCart.ts)
- [Todo App](./src/components/examples/TodoApp.ts)
## ๐ Showcase & Community
- **Showcase your components!** Open a PR to add your project to our gallery.
- **Questions or ideas?** [Start a discussion](https://github.com/jasonshimmy/custom-elements-runtime/discussions) or [open an issue](https://github.com/jasonshimmy/custom-elements-runtime/issues).
- **Contribute:** We welcome PRs for docs, features, and examples.
- โค๏ธ Like what you see? [Support ongoing development on Patreon](https://patreon.com/jshimkoski)
## ๐ 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](https://patreon.com/jshimkoski) to help keep the momentum going.
Your support helps fund continued development, documentation, and community engagement. Every bit helpsโthank you!