@impulsedev/link
v1.0.0
Published
`link` is an in-memory storage layer for web apps.
Readme
Link
link is an in-memory storage layer for web apps.
It keeps data in RAM while the app is alive. When the app is about to close, suspend, or crash, link writes an encrypted snapshot to localStorage. On the next startup, it restores that snapshot back into memory and removes it from localStorage
Install
bun add @impulsedev/linkBasic usage
import { link } from "@impulsedev/link"
const store = link({
adapter: link.adp.nextjs(),
})
await store.ready
store.set("count", 1)
store.mutate<number>("count", (current) => (current ?? 0) + 1)
console.log(store.get("count"))Framework helpers
import { createLinkContext } from "@impulsedev/link/nextjs"
import { createLinkPlugin, useLinkValue } from "@impulsedev/link/nuxt"
import { createLinkBindings } from "@impulsedev/link/vite"
import { createLinkValue } from "@impulsedev/link/sveltekit"
import { createLinkValue as createAstroLinkValue } from "@impulsedev/link/astro"Adapters
link.adp.nextjs()link.adp.nuxt()link.adp.astro()link.adp.sveltekit()link.adp.vite()link.adp.node()
Notes
- Default persistence strategy is
on-exit - Browser adapters use encrypted snapshots
- The in-memory limit is configurable with
maxBytes - Browser storage limits are usually much smaller than the RAM limit
