npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@instant3p/core-offline

v0.20.12012

Published

Instant's core local abstraction - Offline Fork

Readme

3rd party offline-first fork of Instant's vanilla javascript SDK.

db.subscribeQuery({ todos: {} }, (resp) => {
  if (resp.error) {
    renderError(resp.error.message);
    return;
  }
  if (resp.data) {
    render(resp.data); // wohoo!
  }
});

Get Started

This is a 3rd party fork providing offline-first capabilities. See the sections below for usage.

Questions?

If you have any questions, feel free to drop us a line on our Discord

An offline-only fork of Instant's core package that pretends to be online while operating entirely offline.

Overview

This package is a minimal fork of Instant's core that makes the following key changes:

  1. Always reports offline status - Uses OfflineNetworkListener instead of WindowNetworkListener
  2. Works with cached data - Queries work with locally cached data from IndexedDB
  3. Enqueues transactions - All transactions are marked as "enqueued" and stored locally
  4. Improved queryOnce - Returns cached data when offline instead of rejecting

Key Changes Made

1. OfflineNetworkListener.js (New)

// Always reports offline, never attempts WebSocket connections
export default class OfflineNetworkListener {
  static async getIsOnline() {
    return false; // Always offline
  }
  
  static listen(f) {
    f(false); // Always report offline
    return () => {}; // No-op unsubscribe
  }
}

2. Modified index.ts

// Uses OfflineNetworkListener by default instead of WindowNetworkListener
import OfflineNetworkListener from './OfflineNetworkListener.js';

// Changed default network listener
NetworkListener || OfflineNetworkListener

3. Enhanced Reactor.js

// Enhanced queryOnce to work with cached data when offline
if (!this._isOnline) {
  const cachedResult = this.getPreviousResult(q);
  if (cachedResult) {
    dfd.resolve(cachedResult);
    return dfd.promise;
  }
}

How It Works

  1. Initialization: Creates a Reactor instance that never attempts WebSocket connections
  2. Data Storage: All data is stored in IndexedDB like normal InstantDB
  3. Query Engine: Uses InstantDB's existing query engine with cached data
  4. Transactions: Transactions are stored locally and marked as "enqueued"
  5. Relationships: Full support for deep nested relationships using InstantDB's link system

Installation

# Build the package
cd packages/core-offline
npm run build

Usage

Basic Usage

import { init } from '@instant3p/core-offline';

const db = init({
  appId: 'your-app-id',
  schema: {
    entities: {
      users: {
        id: { type: 'string', unique: true },
        name: { type: 'string' },
        email: { type: 'string' }
      }
    }
  }
});

// Subscribe to queries (works with cached data)
db.subscribeQuery({ users: {} }, (result) => {
  console.log('Users:', result.data);
});

// Transactions (will be enqueued)
await db.transact([
  db.tx.users['user-1'].update({
    name: 'John Doe',
    email: '[email protected]'
  })
]);

With Relationships

const db = init({
  appId: 'your-app-id',
  schema: {
    entities: {
      users: { /* ... */ },
      posts: { /* ... */ },
      comments: { /* ... */ }
    },
    links: {
      authoredPosts: {
        from: { entity: 'users', has: 'many', label: 'posts' },
        to: { entity: 'posts', has: 'one', label: 'author' }
      },
      postComments: {
        from: { entity: 'posts', has: 'many', label: 'comments' },
        to: { entity: 'comments', has: 'one', label: 'post' }
      }
    }
  }
});

// Deep nested queries work!
db.subscribeQuery({
  users: {
    posts: {
      comments: {
        author: {}
      }
    }
  }
}, (result) => {
  console.log('Deep nested data:', result.data);
});

Testing

Integration Test

A comprehensive integration test suite is included in the __tests__ directory:

# Run all tests
npm test

# Run only integration tests
npm run test:integration

# Run integration tests in watch mode
npm run test:integration:watch

The integration test covers:

  • Connection Status - Verifies offline status
  • Query Subscriptions - Tests deep nested relationship queries
  • Transactions - Tests creating entities and linking them
  • QueryOnce - Tests one-time queries with cached data
  • Data Persistence - Tests data survival across restarts
  • Real Browser Environment - Uses fake-indexeddb for IndexedDB simulation

Test Features

  • Vitest Framework - Fast, modern test runner
  • Browser Environment Simulation - Uses fake-indexeddb for realistic testing
  • Comprehensive Coverage - Tests all major offline functionality
  • Automated - Runs in CI/CD pipelines
  • Watch Mode - Automatically reruns tests on changes

Differences from Original InstantDB

What Works

  • ✅ All query patterns (simple, nested, relationships)
  • ✅ Transactions (stored locally)
  • ✅ Schema management
  • ✅ IndexedDB persistence
  • ✅ Subscription system
  • ✅ Deep relationship traversal

What's Different

  • 🔄 Always offline - Never attempts server connections
  • 🔄 Transactions enqueued - All transactions marked as "enqueued"
  • 🔄 No real-time sync - Data only exists locally
  • 🔄 No auth - Authentication features don't work
  • 🔄 No presence - Presence features don't work
  • 🔄 No file storage - File upload/download doesn't work

Architecture

This fork maintains InstantDB's core architecture while removing server dependencies:

┌─────────────────────────────────────────────────────────────┐
│                    Application Layer                        │
├─────────────────────────────────────────────────────────────┤
│                    @instantdb/core-offline                  │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐│
│  │   Query Engine  │  │  Transaction    │  │   Link System   ││
│  │                 │  │   Processing    │  │                 ││
│  └─────────────────┘  └─────────────────┘  └─────────────────┘│
├─────────────────────────────────────────────────────────────┤
│                    Storage Layer                            │
│  ┌─────────────────┐  ┌─────────────────┐                   │
│  │   IndexedDB     │  │ OfflineNetwork  │                   │
│  │   Storage       │  │   Listener      │                   │
│  └─────────────────┘  └─────────────────┘                   │
└─────────────────────────────────────────────────────────────┘

Why This Approach?

Instead of reimplementing InstantDB's query engine from scratch, this fork:

  1. Leverages existing code - Uses 99% of InstantDB's existing functionality
  2. Minimal changes - Only ~50 lines of code changed
  3. Maintains compatibility - Same API, same behavior
  4. Proven query engine - Uses InstantDB's battle-tested query system
  5. Easy to maintain - Simple to merge updates from upstream

This approach gives you a fully functional offline database with InstantDB's powerful query capabilities while maintaining the exact same API.