svelte-runes-store is a svelte package to build (persistent) svelte states that can be shared among components through the context.
- WORKS WITH SVELTE 5 AND SVELTEKIT.
- USES THE SVELTE 5 RUNES.
- PERSISTENT AND NON-PERSISTENT STORES.
- TYPESCRIPT SUPPORT.
- ADDS STORES TO THE CONTEXT, AVOIDING STATE SHARING IN SSR.
npm install svelte-runes-store
To run the examples from /src/routes
:
git clone https://github.com/joaquimnetocel/svelte-runes-store.git
cd svelte-runes-store
npm install
npm run dev
store.create
: Function to create the store.store.read
: Function to read the store.
- PARAMETERS OF
store.create
:
PARAMETER | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
---|---|---|---|---|
value |
INITIAL VALUE OF THE STORE. | Generic |
YES | - |
key |
CONTEXT KEY. | string |
YES | - |
storage |
STORAGE TYPE. | localStorage OR sessionStorage |
NO | localStorage |
- PARAMETERS OF
store.read
:
PARAMETER | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
---|---|---|---|---|
key |
CONTEXT KEY. | string |
YES | - |