{"id":48806,"library":"nuxt-storage","title":"nuxt-storage","description":"Utilities for easy read and write browser's storage in Nuxt.js projects, wrapping localStorage and sessionStorage with a simple API. Version 1.2.2 (latest, not actively updated since 2019). Provides get, set (with expiry), and clear methods. Specifically solves the Nuxt SSR hydration issue where direct access to browser storage causes errors. A lighter alternative to larger libraries like vue-store or vue-web-storage.","status":"maintenance","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/mazipan/nuxt-storage","tags":["javascript","nuxt","nuxt-storage","browser-storage","local-storage","session-storage"],"install":[{"cmd":"npm install nuxt-storage","lang":"bash","label":"npm"},{"cmd":"yarn add nuxt-storage","lang":"bash","label":"yarn"},{"cmd":"pnpm add nuxt-storage","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import in client-side Nuxt. Do not destructure unless importing explicitly from subpaths.","wrong":"const nuxtStorage = require('nuxt-storage').default","symbol":"default","correct":"import nuxtStorage from 'nuxt-storage'"},{"note":"Named export only available from subpath, not the main entry.","wrong":"import { setData } from 'nuxt-storage'","symbol":"setData","correct":"import { setData } from 'nuxt-storage/local-storage'"},{"note":"Session-storage variant must be imported from its own subpath.","wrong":"import { getData } from 'nuxt-storage'","symbol":"getData","correct":"import { getData } from 'nuxt-storage/session-storage'"}],"quickstart":{"code":"// Install: npm i nuxt-storage\nimport nuxtStorage from 'nuxt-storage'\n\n// Store data with 5-hour expiry\nnuxtStorage.localStorage.setData('token', 'abc123', 5, 'h')\n\n// Retrieve data\nconst token = nuxtStorage.localStorage.getData('token')\nconsole.log(token) // 'abc123'\n\n// Check if data exists\nif (token) {\n  console.log('Token found')\n} else {\n  console.log('Token expired or missing')\n}\n\n// Clear all localStorage\nnuxtStorage.localStorage.clear()","lang":"typescript","description":"Set, get, and clear localStorage with optional expiry (hours) using the default import."},"warnings":[{"fix":"Wrap usage with `if (process.client)` or use inside `mounted()`","message":"Do not use outside of client-side hooks (e.g. before mounted) – server-side render will fail","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using localforage or integrating directly with browser Storage API","message":"Package is no longer actively maintained; last update 2019","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Do not manipulate localStorage keys manually if using nuxt-storage expiry","message":"Expiry is stored only in localStorage as a JSON value; modifying storage externally may break expiry","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the exact import path as documented; check node_modules folder if unsure","message":"Import from subpaths like 'nuxt-storage/local-storage' must be the exact string; no auto-complete","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.2':25 '2019':31 'access':49 'activ':28 'altern':57 'api':23 'browser':10,51,76 'browser-storag':75 'caus':53 'clear':38 'direct':48 'easi':6 'error':54 'expiri':36 'get':33 'hydrat':45 'issu':46 'javascript':70 'larger':59 'latest':26 'librari':60 'lighter':56 'like':61 'local':79 'local-storag':78 'localstorag':17 'method':39 'nuxt':2,43,71,73 'nuxt-storag':1,72 'nuxt.js':14 'project':15 'provid':32 'read':7 'session':82 'session-storag':81 'sessionstorag':19 'set':34 'simpl':22 'sinc':30 'solv':41 'specif':40 'ssr':44 'storag':3,12,52,69,74,77,80,83 'store':64 'updat':29 'util':4 'version':24 'vue':63,67 'vue-stor':62 'vue-web-storag':66 'web':68 'wrap':16 'write':9","created_at":"2026-06-07T16:58:33.859654+00:00","updated_at":"2026-06-07T16:58:33.859654+00:00","problems":[{"fix":"Use `if (process.client)` before accessing, or call inside `mounted()` lifecycle hook","cause":"Server-side rendering tries to access window/localStorage which is undefined in Node","error":"TypeError: Cannot read properties of undefined (reading 'getItem')"},{"fix":"Create a manual declaration file: `declare module 'nuxt-storage/local-storage';`","cause":"TypeScript definitions are not included; package has no types","error":"Cannot find module 'nuxt-storage/local-storage' or its corresponding type declarations"},{"fix":"Only store data serializable to JSON; use `JSON.stringify` before storing","cause":"Storing non-serializable data or data without JSON.stringify","error":"Uncaught SyntaxError: Unexpected token N in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mazipan/nuxt-storage#readme","github":"https://github.com/mazipan/nuxt-storage","docs":null,"changelog":null,"pypi":null,"npm":"nuxt-storage","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}