A simple and reliable persistence adapter for SignalDB in Tauri applications. Persist your reactive data collections to the local filesystem with optional encryption support.
- π Zero Configuration - Works out of the box with sensible defaults
- πΎ Native Tauri Integration - Uses Tauri's secure filesystem API
- π Optional Encryption - Protect your data with custom encryption functions
- π± Cross-Platform - Works on Windows, macOS, and Linux
- π― Type Safe - Full TypeScript support with comprehensive type definitions
- β‘ Zero Dependencies - No runtime dependencies, maximum performance
- π Auto-Recovery - Graceful handling of corrupted or missing files
Install the package using your preferred package manager:
# npm
npm install @pitzzahh/signaldb-adapter-tauri
# yarn
yarn add @pitzzahh/signaldb-adapter-tauri
# pnpm
pnpm add @pitzzahh/signaldb-adapter-tauri
# bun
bun add @pitzzahh/signaldb-adapter-tauriimport { Collection } from '@signaldb/core';
import { createTauriFileSystemAdapter } from '@pitzzahh/signaldb-adapter-tauri';
// Create a collection with filesystem persistence
const users = new Collection({
name: 'users',
persistence: createTauriFileSystemAdapter('users.json')
});
// Your data is now automatically persisted to the filesystem!
users.insert({ name: 'John Doe', email: 'john@example.com' });π Need more examples? Check out our Usage Examples in the wiki.
const adapter = createTauriFileSystemAdapter('secure-data.json', {
encrypt: async (data) => btoa(JSON.stringify(data)),
decrypt: async (encoded) => JSON.parse(atob(encoded))
});π Want stronger encryption? See our Security Guide for production-ready encryption examples.
import { BaseDirectory } from '@tauri-apps/plugin-fs';
const adapter = createTauriFileSystemAdapter('app-data.json', {
base_dir: BaseDirectory.AppConfig
});π Learn about all storage options: Storage Configuration
Creates a new persistence adapter instance.
| Parameter | Type | Required | Description |
|---|---|---|---|
filename |
string |
β | Name of the file to store data in |
options |
AdapterOptions |
β | Configuration options |
| Option | Type | Default | Description |
|---|---|---|---|
base_dir |
BaseDirectory |
AppLocalData |
Tauri base directory for file storage |
encrypt |
EncryptFunction<T> |
undefined |
Custom encryption function |
decrypt |
DecryptFunction<T> |
undefined |
Custom decryption function |
security |
Partial<SecurityOptions> |
{} |
Security configuration options |
export type EncryptFunction<T> = (data: T[]) => Promise<string>;
export type DecryptFunction<T> = (encrypted: string) => Promise<T[]>;
export interface SecurityOptions {
/** Whether to enforce encryption (throw error if encrypt/decrypt not provided) */
enforceEncryption: boolean;
/** Whether to allow fallback to plaintext on decryption failure */
allowPlaintextFallback: boolean;
/** Whether to validate decrypted data structure */
validateDecryptedData: boolean;
/** Whether callback errors should propagate */
propagateCallbackErrors: boolean;
/** Custom data validator function */
dataValidator: <T>(data: unknown) => data is T[];
/** Whether to create backup files on save (default: false for sync scenarios) */
createBackups: boolean;
/** Maximum number of backup files to keep (default: 5) */
maxBackups: number;
}
export interface AdapterOptions<T> {
base_dir?: import('@tauri-apps/plugin-fs').BaseDirectory;
encrypt?: EncryptFunction<T>;
decrypt?: DecryptFunction<T>;
security?: Partial<SecurityOptions>;
}π For complete API documentation and advanced configuration options, visit our Wiki.
- Tauri: v2.0+ with
@tauri-apps/plugin-fs - SignalDB: v1.0+
- Node.js: v18.0+
- TypeScript: v5.0+ (recommended)
Note: This adapter has zero runtime dependencies. All required packages are peer dependencies that should already be installed in your Tauri + SignalDB project.
Files are stored in platform-specific directories:
| Platform | Default Location |
|---|---|
| Linux | ~/.local/share/[app-name]/ |
| Windows | %APPDATA%/[app-name]/ |
| macOS | ~/Library/Application Support/[app-name]/ |
ποΈ Need help with custom storage locations? Check our Storage Configuration Guide.
For detailed guides and examples, visit our Wiki:
- π Usage Examples - Real-world examples and patterns
- π Security Guide - Encryption best practices and examples
- π Storage Configuration - Custom directories and file management
- β‘ Performance Tips - Optimization strategies
- π§ Troubleshooting - Common issues and solutions
- ποΈ Migration Guide - Upgrading from other adapters
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- SignalDB - The reactive database this adapter is built for
- Tauri - The framework that makes secure desktop apps possible
- Bun - The fast JavaScript runtime used for development