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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mote-software/tinybase-persister-expo-file-system

v1.1.2

Published

TinyBase persister for Expo FileSystem

Readme

TinyBase Persister for Expo FileSystem

A TinyBase persister that uses Expo FileSystem for persistent storage in React Native Expo apps.

Features

  • Persists TinyBase stores to the device filesystem using Expo FileSystem API (v54)
  • Auto-save and auto-load capabilities for seamless data synchronization
  • Full TypeScript support with complete type definitions
  • Compatible with both Store and MergeableStore
  • Built on TinyBase v6+ with zero additional runtime dependencies
  • Automatic file change polling for multi-instance synchronization

What is Persistence?

TinyBase Stores exist only in memory by default. Persisters solve this by enabling you to save and load your Store data to various storage backends. This is essential for:

  • Maintaining application state across app restarts and device reboots
  • Preserving user data between sessions
  • Creating offline-first mobile applications
  • Synchronizing data with external storage

Learn more about TinyBase persistence.

Usage

Assumes your Expo app already has Tinybase installed.

# npm
npm install @mote-software/tinybase-persister-expo-file-system

# pnpm
pnpm add @mote-software/tinybase-persister-expo-file-system

# yarn
yarn add @mote-software/tinybase-persister-expo-file-system

Peer Dependencies

This package requires:

  • tinybase ^6.0.0
  • expo-file-system ^19.0.17

Usage

import { createStore } from 'tinybase';
import { createExpoFileSystemPersister } from '@mote-software/tinybase-persister-expo-file-system';
import * as FileSystem from 'expo-file-system';

// Create a TinyBase store
const store = createStore();

// Define the file path (using Expo FileSystem v19+ API)
const filePath = `${new FileSystem.Directory(FileSystem.Paths.document).uri}/my-store.json`;

// Create the persister
const persister = createExpoFileSystemPersister(
  store,
  filePath,
  (error) => {
    console.error('Persister error:', error);
  }
);

// Load existing data and start auto-saving
await persister.startAutoLoad();
await persister.startAutoSave();

// Now your store is automatically persisted!
store.setCell('pets', 'fido', 'species', 'dog');
// This change is automatically saved to the file system

API Reference

createExpoFileSystemPersister

Creates a new persister instance that uses Expo FileSystem for storage.

function createExpoFileSystemPersister(
  store: Store | MergeableStore,
  filePath: string,
  onIgnoredError?: (error: any) => void
): ExpoFileSystemPersister

Parameters:

  • store - The TinyBase Store or MergeableStore to persist
  • filePath - Absolute path to the file (e.g., `${new FileSystem.Directory(FileSystem.Paths.document).uri}/store.json`)
  • onIgnoredError - Optional callback for handling non-critical errors

Returns: An ExpoFileSystemPersister instance with all standard TinyBase Persister methods.

ExpoFileSystemPersister

Extends the standard TinyBase Persister interface with an additional method:

getFilePath()

Returns the file path used by this persister.

const filePath = persister.getFilePath();

Common Methods

All standard TinyBase Persister methods are available:

// Manual operations
await persister.save();    // Manually save store to file
await persister.load();    // Manually load store from file

// Automatic synchronization
await persister.startAutoSave();  // Auto-save on store changes
await persister.startAutoLoad();  // Auto-load on file changes
await persister.stopAutoSave();
await persister.stopAutoLoad();

// Status
const stats = persister.getStats();  // Get persistence statistics

File Change Detection

This persister uses a polling mechanism (checking every 1 second) to detect external file changes when startAutoLoad() is active. This enables synchronization between multiple app instances or external file modifications.

Example Project

Check out the complete example app in the apps/example directory of this repository for a working demonstration with a persistent counter.

Contributing

See CONTRIBUTORS.md for development setup, building, testing, and contribution guidelines.

Resources

License

MIT