livewire-rust 0.1.3

Livewire for Rust: server-rendered reactive components for Laravel for Rust.
Documentation
# Livewire for Rust

[![CI](https://github.com/sdbruder/livewire-rust/actions/workflows/ci.yml/badge.svg)](https://github.com/sdbruder/livewire-rust/actions/workflows/ci.yml)
[![Docs](https://img.shields.io/badge/docs-localdev.it%2Flivewire--rust-fb70a9)](https://localdev.it/livewire-rust/)

Server-rendered reactive components for [Laravel for Rust](https://laravel.com/rust). This crate is
the server half of a port of [Livewire](https://livewire.laravel.com) 4.x, pinned to the upstream
commit `e8ffabe`; the browser runtime under `js/` and `dist/` is Livewire's own and is reused
unchanged.

The documentation site is at <https://localdev.it/livewire-rust/>, and its source is `docs/`. A deployed example plays
through every capability at <https://livewire-rust-example.bruder.com.br/>. What is tested is in `STATUS.md`; the release notes — features, known
shortcomings, the path to parity, and what differs from PHP by design — are in `CHANGELOG.md`.

## Install

```sh
cargo add livewire-rust
# with model references and pagination, plus one database driver:
cargo add livewire-rust --features database-sqlite
```

The crate is `livewire-rust`; the library it provides is `livewire`, so the first line of a file
that uses it is `use livewire::…`. The manifest pins the framework at `=0.1.4`.

```rust
use livewire::{LivewireComponent, component};

#[derive(Default, LivewireComponent)]
#[livewire(view = "livewire.counter")]
pub struct Counter {
    pub count: i32,
    #[livewire(locked)]
    pub id: String,
}

#[component]
impl Counter {
    pub fn mount(&mut self, count: Option<i32>) {
        self.count = count.unwrap_or(0);
        self.id = laravel::str::random(20);
    }

    pub fn increment(&mut self) {
        self.count += 1;
    }
}
```

Register the components once, in the provider:

```rust
use livewire::LivewireServiceProvider;

laravel::Application::configure().with_providers(|providers| {
    providers.add(LivewireServiceProvider::new(|components: &mut livewire::ComponentRegistry| {
        components.register::<Counter>("counter").expect("unique");
    }));
});
```

A page then renders it with `{{ livewire("counter", {"count": 5}) }}`, and the response carries the
styles and scripts. The runtime posts each interaction back to `/livewire-<hash>/update`, where the
server verifies the signed snapshot, runs the component, and answers with new markup and effects.

`../laravel-rust` is a working application with a `counter` component on `/livewire/counter`;
`tests/livewire.rs` there exercises every protocol path.

## Features

`database` adds model synths, paginators, and persistent middleware, and needs a driver beside it:
`database-sqlite`, `database-mysql`, or `database-postgres`. The framework's `database` feature
alone leaves its connection enum empty, so enabling it without one cannot compile.

## What works, and what does not

[`STATUS.md`](STATUS.md) lists each area with the test or command that proves it, and each gap
without one. It is the only current list: this file does not duplicate it.

## Development

```sh
scripts/check.sh        # format, features, clippy, docs, tests, and the runtime suite
cargo test --workspace --all-features
npm ci && npm run build # rebuilds dist/, byte-identically
```

`AGENTS.md` records the conventions these gates enforce, and `.github/workflows/ci.yml` runs the same
checks for every push.

`dist/` is committed, so an application that depends on this crate never runs Node.

## License

MIT, as [`LICENSE.md`](LICENSE.md) records. The vendored runtime and the protocol it speaks are
Livewire's, copyright Caleb Porzio, under the same license.