local-first-patterns

Implement offline-first persistence with OPFS, browser SQLite, and a sync engine.

Updated Jan 25, 2026
One-click install
npx skills add https://github.com/houke/nexus-playground --skill local-first-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: local-first-patterns
Source: https://github.com/houke/nexus-playground/tree/main/.github/skills/local-first-patterns
Command: npx skills add https://github.com/houke/nexus-playground --skill local-first-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured approach to building offline-first applications by combining OPFS-based storage, in-browser SQLite, and a resilient sync pipeline. It enables apps to continue functioning without network connectivity and to reconcile changes when back online.

Core Features & Use Cases

  • Offline-first architecture: local storage with eventual synchronization
  • OPFS for persistent file storage and fast I/O
  • In-browser SQLite via sql.js or wa-sqlite for relational data
  • Deterministic conflict resolution and a pluggable sync engine
  • Use cases include note-taking apps, form-heavy data collection, and offline-first dashboards

Quick Start

Initialize an application with OPFS as the storage backend, set up a browser SQLite instance, and start a local sync queue that pushes changes when online.

Frequently Asked Questions about local-first-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an offline-first web app with persistent SQLite storage?

Build offline-first apps by combining OPFS for persistent file storage with in-browser SQLite via sql.js or wa-sqlite. This approach enables relational data persistence directly in the browser, allowing web apps to function without network connectivity.

How does conflict resolution work for client-side sync queues in offline-first apps?

Conflict resolution in offline-first apps uses a deterministic sync engine to reconcile changes when back online. A local sync queue manages pending modifications and applies deterministic rules to resolve data conflicts consistently during synchronization.

Can I use Drizzle ORM with browser SQLite for offline data persistence?

Yes, Drizzle ORM works with in-browser SQLite instances powered by sql.js or wa-sqlite. This combination provides structured relational data management and query building for offline-first web applications using OPFS as the storage backend.

What is OPFS and when do I need it for offline-first web applications?

OPFS, or Origin Private File System, provides persistent file storage with fast synchronous I/O in the browser. You need OPFS when building offline-first PWAs that require reliable local data persistence and high-performance file system access.

What is the best way to sync local SQLite data when network connectivity is restored?

The best way to sync local SQLite data is by implementing a local sync queue that detects when online status returns. The queue pushes queued changes to the server and uses a deterministic conflict resolution engine to reconcile any divergent modifications.

What are the limitations of using OPFS and in-browser SQLite for offline-first apps?

Limitations of OPFS and in-browser SQLite include the strict requirement for browser OPFS access and the complexity of managing a local sync queue. Users must handle deterministic conflict resolution carefully to prevent data loss during synchronization.