Skip to content

harshalmore31/fluid-pwa

Repository files navigation

๐Ÿš€ Fluid PWA Framework

The Ultimate Offline-First Progressive Web App Framework
Rapid PWA development with multiple batteries for seamless offline experiences

npm version Apache 2.0 License TypeScript Next.js PRs Welcome


โœจ What is Fluid PWA?

Fluid PWA is a production-ready framework that makes building offline-first Progressive Web Apps effortless. It provides a robust, configurable, and developer-friendly solution for rapid PWA development with multiple batteries for offline data management and automatic synchronization status tracking.

๐ŸŽฏ Built for Developers, by a Developer

  • ๐Ÿ”ง Zero Configuration - Works out of the box with sensible defaults
  • ๐ŸŽฃ React Hooks - Clean, composable API that feels natural
  • ๐Ÿ“ฑ Offline-First - Designed to work seamlessly without internet
  • ๐Ÿ”„ Sync Management - Automatic tracking of pending changes
  • ๐Ÿ’ช TypeScript - Full type safety with intelligent inference
  • โšก Performance - Optimized for speed and efficiency

Open Source: This project is created and maintained by @harshalmore31 as an open-source initiative to provide the ultimate offline-first PWA framework.


๐Ÿš€ Quick Start

Installation

npm install fluid-pwa dexie dexie-react-hooks uuid
# or
yarn add fluid-pwa dexie dexie-react-hooks uuid
# or
pnpm add fluid-pwa dexie dexie-react-hooks uuid

Basic Setup

import { FluidPWAProvider, FluidPWAConfig } from 'fluid-pwa'

// 1. Define your data schema
const schema = {
  notes: '++localId, title, content, syncStatus, lastModifiedOffline, userId',
  tasks: '++localId, title, completed, priority, syncStatus, lastModifiedOffline, userId'
}

// 2. Configure Fluid PWA
const config: FluidPWAConfig = {
  databaseName: 'MyApp',
  schema,
  version: 1,
  enableLogging: true
}

// 3. Wrap your app
export default function App() {
  return (
    <FluidPWAProvider config={config}>
      <MyApp />
    </FluidPWAProvider>
  )
}

Use in Components

import { useAddItem, useGetAllItems, useUpdateItem, useDeleteItem } from 'fluid-pwa'

function NotesApp() {
  const addNote = useAddItem<Note>('notes')
  const notes = useGetAllItems<Note>('notes')
  const updateNote = useUpdateItem<Note>('notes')
  const deleteNote = useDeleteItem('notes')

  const handleAdd = async () => {
    const result = await addNote({
      title: 'My Note',
      content: 'This works offline!'
    })
    
    if (result.success) {
      console.log('โœ… Note saved with ID:', result.data)
    }
  }

  return (
    <div>
      <button onClick={handleAdd}>Add Note</button>
      {notes?.map(note => (
        <div key={note.localId}>
          <h3>{note.title}</h3>
          <span>{note.syncStatus}</span> {/* PENDING_CREATE, SYNCED, etc. */}
        </div>
      ))}
    </div>
  )
}

๐ŸŒŸ Key Features

๐Ÿ”„ Automatic Sync Status Management

Every data change is automatically tracked with sync statuses like PENDING_CREATE, PENDING_UPDATE, SYNCED, making it easy to implement data synchronization.

๐ŸŽฃ Powerful React Hooks

  • useAddItem - Create new items with validation hooks
  • useGetAllItems - Reactive queries with filtering and sorting
  • useUpdateItem - Update with automatic sync status handling
  • useDeleteItem - Smart deletion (hard/soft delete based on sync status)
  • useGetPendingItems - Get items that need to be synced
  • useFluidPWAStats - Database statistics for monitoring

โšก Live Reactive Updates

Built on Dexie's live queries - your UI automatically updates when data changes, even across browser tabs!

๐Ÿ›ก๏ธ Type Safety

Full TypeScript support with intelligent type inference:

interface Note {
  title: string
  content: string
}

const notes = useGetAllItems<Note>('notes') // Fully typed!

๐Ÿ”ง Configurable & Extensible

const addNote = useAddItem<Note>('notes', {
  onBeforeAdd: async (note) => {
    // Validation, transformation, etc.
    return { ...note, slug: generateSlug(note.title) }
  },
  onAfterAdd: async (note, id) => {
    // Analytics, notifications, etc.
    analytics.track('Note Created', { id })
  }
})

๐Ÿ“ฑ Live Demo

Experience Fluid PWA in action:

๐ŸŒ View the Demo

The demo showcases:

  • โœ… Creating and managing notes offline
  • โœ… Real-time sync status indicators
  • โœ… Database statistics dashboard
  • โœ… Works completely offline
  • โœ… Multi-tab synchronization

๐Ÿ“š Documentation

Core Concepts

Advanced Topics


๐Ÿ—๏ธ Architecture

Fluid PWA is built on a solid foundation:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          React Components          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚         Fluid PWA Hooks            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚        Dexie.js Database           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚         IndexedDB API              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Phase 1 (Current): Foundation & Core CRUD Operations
Phase 2 (Coming): Background Sync & Conflict Resolution
Phase 3 (Future): Real-time Collaboration & Advanced Sync


๐Ÿค Contributing

We welcome contributions! Fluid PWA is built by the community, for the community.

๐Ÿš€ Quick Contribution Setup

# 1. Fork & Clone
git clone https://github.com/YOUR_USERNAME/fluid-pwa.git
cd fluid-pwa

# 2. Install dependencies
npm install

# 3. Start development
npm run dev

# 4. Make your changes and test
npm run test

# 5. Submit a PR!

๐Ÿ“‹ Contribution Areas

  • ๐Ÿ› Bug Fixes - Help us squash bugs
  • โœจ New Features - Add hooks, utilities, or integrations
  • ๐Ÿ“– Documentation - Improve guides and examples
  • ๐Ÿงช Testing - Add test cases and improve coverage
  • ๐ŸŽจ Examples - Create real-world usage examples
  • ๐Ÿš€ Performance - Optimize queries and operations

๐Ÿ“ Development Guidelines

  1. Code Style: We use ESLint and Prettier
  2. Testing: Add tests for new features
  3. Documentation: Update docs for API changes
  4. TypeScript: Maintain strict type safety
  5. Commits: Use conventional commit messages

๐Ÿ›ฃ๏ธ Roadmap

โœ… Phase 1: Foundation (Current)

  • Core Dexie.js integration
  • React hooks for CRUD operations
  • Automatic sync status tracking
  • TypeScript support
  • Provider pattern
  • Comprehensive documentation

๐Ÿšง Phase 2: Enhanced Sync (Next)

  • Background sync with Service Workers
  • Conflict resolution strategies
  • Retry mechanisms with exponential backoff
  • Batch operations optimization
  • Advanced error handling

๐Ÿ”ฎ Phase 3: Advanced Features (Future)

  • Real-time collaboration
  • Multi-device synchronization
  • Encryption support
  • Plugin architecture
  • Cloud storage integrations

๐Ÿ“Š Why Choose Fluid PWA?

Feature Fluid PWA Manual Setup Other Solutions
Setup Time 5 minutes Days/Weeks Hours
TypeScript โœ… Built-in ๐Ÿ”ง Manual โŒ Limited
Sync Status โœ… Automatic ๐Ÿ”ง Manual โŒ None
React Hooks โœ… Optimized ๐Ÿ”ง Build Your Own โŒ Limited
Offline-First โœ… By Design ๐Ÿ”ง Complex Setup โŒ Afterthought
Testing โœ… Test Utils ๐Ÿ”ง DIY โŒ Difficult

๐ŸŒ Community

Join our growing community of developers building amazing offline-first apps!


๐Ÿ“„ License

Apache 2.0 License - see the LICENSE file for details.


๐Ÿ’ Sponsors

Fluid PWA is open source and free. If you find it useful, consider sponsoring the project:

Sponsor


๐Ÿ™ Acknowledgments

  • Dexie.js - Excellent IndexedDB wrapper used for offline data management
  • Next.js - The React framework that makes PWAs awesome
  • Open Source Community - For the amazing tools and libraries that make this possible

๐ŸŒ Repository โ€ข ๐Ÿ“š Documentation โ€ข ๐Ÿš€ Demo โ€ข ๐Ÿ’ฌ Discussions

Built with โค๏ธ by Harshal More

About

FluidPWA gives you the flexibility to build PWAs your way - use WASM for complex features, JavaScript for everything else, with smooth transitions throughout.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors