alpinejs-app

A Simplest Single Page Application (SPA) library for Alpine.js.

The Vision

New directives

<div x-template="template"></div>

<div x-template="show ? 'index' : ''"></div>

<div x-template.cache="show ? '/path/index.html' : ''"></div>

<a x-render="'hello/hi?reason=World'">Show hello component with params</a>

<button @click="toggle">Call the toggle method in the current component</button>

<button x-render="'index?$target=#div'">Show Bundled or Cached by ID</button>

<button x-render.cache="'/index.html?$target=#div'">Show External File</button>

Component class

app.components.hello = class extends app.AlpineComponent {
    template = ""

    onCreate() {

    }

    onDelete() {

    }

    onToggle(data) {
        console.log("received toggle event:", data)
    }

    toggle() {
        this.template = !this.template ? "example" : "";

        app.emit(app.event, "toggle", this.template)
    }
}

Features

Getting started

Visit the tutorial.

Full documentation

Visit the documentation.

Live demo

Available at demo.

External rendering is not working due pages only serving static content, local demo shows server-side rendering.

Author

Vlad Seryakov

License

Licensed under MIT