gjendje
v1.5.0
Published
Storage-agnostic state management library for TypeScript and JavaScript
Maintainers
Readme
gjendje
gjendje is a storage-agnostic state management library for TypeScript and JavaScript. It gives you a single, unified API for reactive state — regardless of where that state lives.
Install
npm install gjendjeQuick start
import { state } from 'gjendje'
const store = state({ count: 0 })
// set
store.set({ count: 1 })
store.set((prev) => ({ ...prev, count: prev.count + 1 }))
// get
store.get()
const { count } = store.get()
// reset
store.reset()Framework Bindings
React
import { state } from 'gjendje'
import { useGjendje } from 'gjendje/react'
const counter = state({ counter: 0 })
function Counter() {
const [count, setCount, resetCount] = useGjendje(counter)
return <button onClick={() => setCount(prev => prev + 1)}>{count}</button>
}Vue
<script setup>
import { state } from 'gjendje'
import { useGjendje } from 'gjendje/vue'
const counter = state({ counter: 0 })
const count = useGjendje(counter)
</script>
<template>
<button @click="count++">{{ count }}</button>
</template>Svelte
<script>
import { state } from 'gjendje'
import { useGjendje } from 'gjendje/svelte'
const counter = state({ counter: 0 })
const count = useGjendje(counter)
</script>
<button on:click={() => $count++}>
{$count}
</button>API
get, peek, set, patch, mutate, reset, destroy, subscribe, watch, intercept, onChange
Primitives
computed, select, previous, readonly, collection, effect, when, resource, channel, toSignal, fromSignal
Scopes
memory, local, session, url, bucket, server
Utilities
batch, snapshot, destroyAll, withHistory, withWatch, withServerSession
DevTools
Configure
scope, maxKeys, prefix, requireValidation, registry, ssr, sync, warnOnDuplicate, onChange, onDestroy, onError, onExpire, onHydrate, onIntercept, onMigrate, onQuotaExceeded, onRegister, onReset, onSync, onValidationFail
License
MIT
Icon
Created by Gulraiz
