Help us improve
Share bugs, ideas, or general feedback.
Adds client-side data persistence to a Meta Display Glasses webapp using localStorage and sessionStorage. Provides helpers for saving settings, caching data, and persisting state.
npx claudepluginhub facebookincubator/meta-wearables-webapp --plugin meta-wearables-webappHow this skill is triggered — by the user, by Claude, or both
Slash command
/meta-wearables-webapp:add-local-storage [purpose: settings|cache|state|preferences][purpose: settings|cache|state|preferences]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Add client-side data persistence using the standard [W3C Web Storage API](https://www.w3.org/TR/webstorage/). Supports `localStorage` (persists across sessions) and `sessionStorage` (cleared when the session ends). No SDK required.
Connects a Meta Display Glasses webapp to REST APIs or WebSockets with loading/error states and caching. Use when fetching data, adding real-time updates, or handling offline fallback.
Scaffolds Even Hub G2 smart glasses apps from scratch with Vite, TypeScript, SDK, CLI, simulator, and app manifest. Use for new projects or bootstrapping development.
Guides selection and implementation of browser storage APIs (localStorage, sessionStorage, IndexedDB, cookies) with security, cleanup, and quota strategies.
Share bugs, ideas, or general feedback.
Add client-side data persistence using the standard W3C Web Storage API. Supports localStorage (persists across sessions) and sessionStorage (cleared when the session ends). No SDK required.
/create-webapp| API | Persistence | Use Cases |
|---|---|---|
localStorage | Persists until explicitly cleared | User settings, saved data, app state, preferences |
sessionStorage | Cleared when session ends | Temporary state, form drafts, navigation context |
Both APIs share the same interface and store string key-value pairs.
Ask the user:
localStorage) or session-only (sessionStorage)?In app.js, add helpers for reading and writing structured data:
var STORAGE_KEY = 'mdg_myapp';
function saveData(data) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
}
function loadData() {
try {
var saved = localStorage.getItem(STORAGE_KEY);
return saved ? JSON.parse(saved) : null;
} catch (e) {
return null;
}
}
function clearData() {
localStorage.removeItem(STORAGE_KEY);
}
Load saved data on startup and save on changes:
// On init
var saved = loadData();
if (saved) {
state.data = saved;
}
// After any state change
state.data.score = 100;
saveData(state.data);
For user-facing settings with persistence:
case 'toggle-dark-mode':
state.data.darkMode = !state.data.darkMode;
document.body.classList.toggle('light-mode', !state.data.darkMode);
saveData(state.data);
break;
case 'reset-data':
clearData();
state.data = {};
showToast('Data cleared');
break;
function savePreference(key, value) {
var prefs = loadData() || {};
prefs[key] = value;
saveData(prefs);
}
function getPreference(key, defaultValue) {
var prefs = loadData() || {};
return prefs[key] !== undefined ? prefs[key] : defaultValue;
}
function cacheResponse(url, data, ttlMs) {
var entry = { data: data, timestamp: Date.now(), ttl: ttlMs };
localStorage.setItem('cache_' + url, JSON.stringify(entry));
}
function getCachedResponse(url) {
try {
var entry = JSON.parse(localStorage.getItem('cache_' + url));
if (entry && Date.now() - entry.timestamp < entry.ttl) {
return entry.data;
}
} catch (e) {}
return null;
}
Use sessionStorage for data that should not survive a restart:
// Save temporary navigation context
sessionStorage.setItem('returnScreen', 'home');
// Restore on load
var returnTo = sessionStorage.getItem('returnScreen') || 'home';
/add-ui — Add settings screens and toggle buttons/connect-api — Fetch data to cache locally