Skip to content

Help people who use preact signals to persist data to the browser's local/session storage.

Notifications You must be signed in to change notification settings

qingzhoufeihu/signals-persist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Signals with Storage

Signals are awesome. Make them even more awesome by persisting them across sessions.

This library allows you to easily persist your signals across sessions. It works in Preact

It's as simple as this:

import { signalL, signalS } from "@jagger/signals-persist";

export const countWithLocalStorage = signalL("count", 0);
export const countWithSessionStorage = signalS("count", 0);

Installation

npx jsr add @jagger/signals-persist

or

pnpx jsr add @jagger/signals-persist

or

deno add @jagger/signals-persist

Usage

Customize your storage:

import { persistSignal, Storage } from "@jagger/signals-persist";

const storage: Storage = window.localStorage;

export const signalX = <T>(key: string, initialValue: T) =>
  persistSignal(key, initialValue, storage);

About

Help people who use preact signals to persist data to the browser's local/session storage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published