Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Duo Laravel Package

joshcirre/duo

Duo brings local-first IndexedDB syncing to Laravel and Livewire apps. Add one trait and your components become offline-capable Alpine.js, with automatic model caching, optimistic updates, schema extraction, and a sync queue that resumes when you're back online.

View on GitHub
Deep Wiki
Context7
v0.2.0

Duo v0.2.0 โ€” Livewire 4, real offline, no REST layer

Duo is local-first Livewire: your component reads from IndexedDB, applies changes optimistically, and keeps working offline โ€” while your own Livewire methods remain the only thing that writes to your database.

This release is a rewrite of the sync architecture and drops Livewire 3. Upgrade both packages together:

  • Composer: joshcirre/duo ^0.2
  • NPM: [@joshcirre](https://github.com/joshcirre)/vite-plugin-duo ^0.2

What changed

  • Livewire 4 only. Class-based and single-file components. Laravel 12.
  • Writes go through your Livewire methods. No more /api/duo/{table} endpoints. Duo writes an optimistic record, then calls your real $wire method; the server reports the Eloquent operations that ran and the client reconciles. Validation, policies, and events work exactly as in plain Livewire.
  • Optimistic changes roll back when the server did not perform them โ€” a failed validation removes the temp row while Livewire renders the error.
  • Offline actions are queued (localStorage) and replayed through $wire when you're back online, including after a reload.
  • Offline page loads work: with [@duoMeta](https://github.com/duoMeta) in your layout, the service worker caches visited pages and the component boots from IndexedDB with no network.
  • The Alpine duo scope is added server-side, so there is no client-side DOM rewriting and no "duo is not defined" race.
  • Method analysis detects toggles, $this->prop โ†’ column mappings, and literal defaults for accurate optimistic rendering.

Verified in a real browser

Against the workbench demo in headless Chromium: optimistic create/toggle/delete, validation rollback with Livewire-rendered errors, offline queue + replay, recovery from a killed server, replay of a previous session's queue on load, and a full page load with the server down.

Upgrading from 0.1.x

  1. composer require joshcirre/duo:^0.2 and npm install -D [@joshcirre](https://github.com/joshcirre)/vite-plugin-duo@^0.2
  2. Requires livewire/livewire ^4.0.
  3. Add data-duo-* markers to the lists you want rendered from IndexedDB (see the README). Components with WithDuo alone still get page caching and offline action replay.
  4. Remove any code that called /api/duo/* or window.duo.getSyncQueue() (still present as an alias for the action queue).
  5. Clear browsers' IndexedDB once (<x-duo::debug /> โ†’ Delete Database) if you were running 0.1.x locally.

See the CHANGELOG for the full list, and the README for the marker reference and known limitations.

Note: 0.x โ€” the marker vocabulary and JavaScript API may still change.

v0.1.0

Duo v0.1.0 - Local-First Syncing for Laravel & Livewire

First public release of Duo - a local-first IndexedDB syncing package for Laravel and Livewire applications.

๐Ÿ“ฆ Package Information

This release includes:

  • Composer Package: joshcirre/duo - Laravel service provider and traits
  • NPM Package: [@joshcirre](https://github.com/joshcirre)/vite-plugin-duo - Vite plugin and client library

โœจ Features

Core Functionality

  • ๐Ÿ”„ Automatic IndexedDB Syncing - Transparent client-side caching of Eloquent models
  • โšก Optimistic Updates - Instant UI updates with background server synchronization
  • ๐Ÿ“ก Offline Support - Automatic offline detection with sync queue that resumes when back online
  • ๐ŸŽฏ Livewire Integration - Seamless integration with Livewire 3+ and Volt components
  • ๐Ÿš€ Zero Configuration - Add one trait and Duo handles the rest

Full Page Caching

  • ๐Ÿ’พ Offline Page Caching - Complete page caching with service workers
  • ๐Ÿ”ง Dynamic Service Worker - No publishing needed, served automatically from package
  • ๐Ÿ”’ CSRF Protection - [@duoMeta](https://github.com/duoMeta) directive includes CSRF token automatically
  • ๐Ÿ–ผ๏ธ Asset Caching - Caches HTML, CSS, JS, images, and fonts for true offline mode

Developer Experience

  • ๐Ÿ“Š Visual Sync Status - Built-in component showing online/offline/syncing states
  • ๐Ÿ“ฆ Type-Safe - Full TypeScript support with auto-generated types
  • ๐Ÿ”Œ Vite Plugin - Automatic manifest generation with file watching
  • ๐Ÿงช Workbench Demo - Fully functional todo list demo included

๐Ÿ“š Installation

Composer

composer require joshcirre/duo

NPM

npm install -D [@joshcirre](https://github.com/joshcirre)/vite-plugin-duo

๐Ÿš€ Quick Start

  1. Add the Syncable trait to your models:
use JoshCirre\Duo\Syncable;

class Todo extends Model
{
    use Syncable;
}
  1. Add the WithDuo trait to your Livewire/Volt components:
use JoshCirre\Duo\WithDuo;

new class extends Component {
    use WithDuo;
    // ...
}
  1. Add [@duoMeta](https://github.com/duoMeta) to your layout:
<head>
    [@vite](https://github.com/vite)(['resources/css/app.css', 'resources/js/app.js'])
    [@duoMeta](https://github.com/duoMeta)
</head>
  1. Configure Vite:
import duo from '[@joshcirre](https://github.com/joshcirre)/vite-plugin-duo';

export default defineConfig({
    plugins: [duo()],
});

That's it! Your app now has local-first syncing with offline support.

๐Ÿ“– Documentation

๐Ÿ™ Acknowledgments

Built with:

  • Laravel
  • Livewire
  • Dexie.js
  • Vite

๐Ÿ“„ License

MIT License - see LICENSE for details.


Note: This is a 0.x release, meaning the API may change before 1.0. Please report any issues on GitHub.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log