Skip to content

polykv/polykv-typescript

Repository files navigation

PolyKV - TypeScript

npm version License Stars Platforms

Universal, Zero-Config Key-Value Store for Node.js, Browser, and React Native.

PolyKV for TypeScript automates persistence across the entire JavaScript ecosystem. Whether you are building a CLI, a Web App, or a Mobile App, the API remains exactly the same.

One API, Everywhere. This library is part of the PolyKV ecosystem. Use the same consistent API across 12+ languages.

✨ Why PolyKV TS?

  • 🦄 Universal API Write code once. It runs on Node.js (fs), Browser (localStorage), and React Native (AsyncStorage) without changes.

  • 🔄 Polymorphic Storage Detects the environment at runtime and selects the best native storage driver automatically.

  • 📱 React Native Ready Seamlessly integrates with @react-native-async-storage/async-storage. No extra bridging code needed.

📦 Installation

npm install polykv
# or
pnpm add polykv
# or
yarn add polykv

🚀 Usage

Complete Example

import { PolyKV } from 'polykv';

const db = new PolyKV("UserPrefs");

// 1. Save (Set)
await db.setString("theme", "dark");
await db.setNumber("fontSize", 14);
await db.setBool("notifications", true);
await db.setMap("user", { id: 1, name: "Alice" });

// 2. Read (Get)
const theme = await db.getString("theme");
console.log(`Theme: ${theme}`); // "dark"

// 3. Update
await db.setNumber("fontSize", 16); // Overwrites previous value

// 4. Delete (Remove)
await db.remove("theme");
const check = await db.getString("theme");
console.log(check); // null

// 5. Clear All
await db.clear(); // Wipes everything in "UserPrefs"

🌍 Environment Behavior

  • Node.js: Creates JSON files in ~/.config or %APPDATA%.
  • Browser: Persists to localStorage with namespaced keys.
  • React Native: Bridges efficiently to native mobile storage.

🌍 Platform Support

Language Verified Runtime (✅) Build Only (🛠)
TypeScript CLI (Node.js), Browser, React Native (iOS/Android) -
Dart Flutter (iOS/Android/macOS), CLI -
Go macOS, Linux, Windows, iOS, Android, CLI -
Rust macOS, iOS, Android, CLI Linux, Windows
Swift iOS, macOS, CLI -
C++ macOS, iOS, Android, CLI -
Python CLI, Web, Android -
Kotlin CLI, Web, Android -
C# CLI Android, Windows
Java CLI, Android -
Ruby CLI -
PHP CLI -

✅ Runtime Verified: Full CRUD operations verified via automated tests on actual devices/simulators.

📜 License

MIT

About

Zero-Config, Native Key-Value Store for TypeScript/Node.js

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors