wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
12.79k stars 1.14k forks source link

Provide a managed client storage solution #1082

Open infomiho opened 1 year ago

infomiho commented 1 year ago

We want to provide a helper for storing data locally on the clients.

Abstract away the storage implementation

We want to wrap localStorage or sessionStorage (something like https://www.npmjs.com/package/use-browser-storage) and expose it to the user.

import { storage } from '@wasp/storage';

// Sets 'value' at 'key'
storage.set('key', 'value')

// Gets value at 'key'
storage.get('key')

// Removes 'key'
storage.remove('key')

// Clears only things that were set by `storage.set`
storage.clear() 

Help with security

We could provide an API for storing user sensitive data which we could then automatically clear on log out. Something like

storage.setPrivate('key', 'userSpecificData')
Martinsos commented 1 year ago

This might be useful, but I feel like we should do a bit more convincing ourselves before we go into this! What is the benefit of this, why should Wasp do it?