Sprae is a lightweight library that adds reactivity to HTML and JSX without requiring a build step. It allows you to sprinkle :attributes directly onto your HTML tree, which Sprae then evaporates, hydrating the DOM. This approach keeps your existing HTML, JSX, MD, or templates intact, eliminating the need for rewrites.
- HTML-first Approach: Maintain your existing codebase without any rewrites. Sprae works seamlessly with HTML, JSX, Markdown, and server templates.
- Light & Fast: Sprae is designed for performance, offering a faster experience than many popular frameworks. It achieves this by avoiding a virtual DOM and complex build processes.
- No Build Step: Integrate reactivity directly into your project without the overhead of a build pipeline. Sprae works as a script via CDN, locally, or as an ES module.
- CSP-Safe: A dedicated CSP build ensures safe execution of attributes, making it suitable for environments with strict Content Security Policies, such as browser extensions.
- Progressive Enhancement: If Sprae fails to load, your page will gracefully fall back to its original HTML structure.
- Directives: Sprae offers a rich set of directives for managing state, conditionals, lists, events, and more, inspired by Alpine.js but with a focus on minimal syntax.
- State Management: Utilize `:scope` to declare local reactive state, and leverage `preact-signals` or other pluggable signal libraries for advanced state management.
- Custom Elements: Sprae works well with custom elements, passing props and respecting their boundaries.
Sprae is ideal for pages where a full-fledged framework might be overkill, providing a simple yet powerful way to add dynamic behavior to server-rendered HTML.