TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: RemoteStorage – sync localStorage across devices and browsers

129 pointsby pancomplexover 1 year ago
Hey HN! Wanted to share a new library and server I&#x27;ve recently been working on called remoteStorage.<p>When building frontends with Javascript, the native localStorage API is super useful for keeping track of state between sessions in the same browser, but it&#x27;s not as good a solution when your data needs to be shared across multiple devices or browsers.<p>For instance, let&#x27;s say you want to show a welcome modal to all new users that sign up for your product. If you use localStorage to track if a user has already seen this modal, your users will end up getting the experience repeatedly every time they switch devices or browsers, or whenever Chrome decides to nuke your data.<p>I built remoteStorage to help fix that. Using the same API as localStorage, remoteStorage allows you to easily read and write data on the fly while maintaining state across browsers and devices in order to provide a better user experience.<p>The project is built as a monorepo in Typescript and contains a JS library that works across any Javascript stack (including Node.js and React Native) and is lightweight (~1 kb minified). The server is built with Nest.js with a disk-persisted Redis Database. It can be deployed in a few minutes using Docker.<p>One of the biggest challenges when building this was coming up with a secure scheme for handling authentication while still keeping the API dead simple for frontend devs to use. While the project is intended to store non-sensitive data like impression events&#x2F;preferences, I still wanted to make sure data couldn’t easily leak or be tampered with.<p>One solution has been to generate a unique secret UUID per user on your own backend to identify the user. Alternatively, you could create a simple wrapper&#x2F;proxy API around remoteStorage that uses your own authentication method to verify the user&#x27;s identity before allowing them to access the data (this is super simple to build with React Server Components). Then, you could pick a secure and secret Instance ID that is not publicly available to ensure that only your application can access the data.<p>Has anyone felt the same pain points with localStorage before? Is this solution useful? Let me know what you think or ideas for how I can improve it :)

23 comments

paulgbover 1 year ago
Your landing page at <a href="https:&#x2F;&#x2F;remote.storage&#x2F;" rel="nofollow">https:&#x2F;&#x2F;remote.storage&#x2F;</a> is so good, I love the minimalism. Six lines of code tell me exactly what it does.
评论 #38976922 未加载
评论 #38974476 未加载
评论 #38976799 未加载
stevageover 1 year ago
The bit about finding a unique ID for the user is the whole pain point though. The only way to do that really is for the user to create an account on some service that I host. And if I have that, I probably have my own hosted data storage anyway.
评论 #38980267 未加载
joshstrangeover 1 year ago
Very cool overall but the sync-&gt;async change means you can&#x27;t always use it as a drop-in replacement. I assume it&#x27;s making network calls in those cases which will take significantly longer that local writes. I wonder if something could be done so that it write the data locally and kicks off something async in the background to sync it up to the backend. Maybe with just a timestamp in case you go offline to handle conflicts (or even way to register a callback if there is a conflict so you can decide how to handle it). I know that all makes this more complicated but I&#x27;d be worried about adding waiting for a network call where I currently do localStorage calls.<p>But still a very cool project, thank you for sharing!
评论 #38975525 未加载
mxuribeover 1 year ago
At first I got confused, because i thought this was a refreshed version of <a href="https:&#x2F;&#x2F;remotestorage.io" rel="nofollow">https:&#x2F;&#x2F;remotestorage.io</a> ....but, i see now that its different&#x2F;separate.
tcperover 1 year ago
The use case is limited, a project has it&#x27;s own backend, why need to add a new sub-system for tiny data storage?
评论 #38978420 未加载
maxwellgover 1 year ago
On the authentication front - JWTs would be a great fit here!<p>The developer&#x27;s backend could issue a JWT, which is validated by the remoteStorage backend. Then, use the `sub` field as the user ID. JWTs are pretty ubiquitous in frontend applications, so many people would be able to reuse their existing auth setup.
评论 #39112684 未加载
评论 #38974760 未加载
amadeuspagelover 1 year ago
How does this compare to PouchDB[1]?<p>[1]: <a href="https:&#x2F;&#x2F;pouchdb.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pouchdb.com&#x2F;</a>
评论 #38974789 未加载
ocdtrekkieover 1 year ago
&gt; Has anyone felt the same pain points with localStorage before?<p>For Sandstorm, we&#x27;ve always want to make sure app data is stored on a server, but an increasing number of web apps love to use localStorage as a cheap hack to avoid writing a backend. I recall a bunch of attempts back in the day, but we were always looking for a simple way to include something with an app written to use localStorage which could store the data on a server backend instead.
epsover 1 year ago
How are the conflicts resolved?<p>Machine A is online and sets &quot;x&quot; to 1.<p>Machine B is offline and sets &quot;x&quot; to 2.<p>Machine B goes online.<p>What the resulting state on A and on B?<p>What if initially A was offline and B was online?
评论 #38976197 未加载
评论 #38976194 未加载
评论 #38983546 未加载
matlinover 1 year ago
I love the simplicity and kinda wish that was actually built into Chrome.<p>I know it would probably break things but if Google could automatically sync local storage and IndexedDB when I&#x27;m signed into Chrome on all my devices then a lot browser of apps wouldn&#x27;t require making an account or even a server for that matter.
评论 #38977258 未加载
评论 #38974906 未加载
simlevesqueover 1 year ago
That&#x27;s so cool ! I was thinking how I&#x27;d make work syncing my offline first app and this looks promising
评论 #38975150 未加载
评论 #38976876 未加载
评论 #38975231 未加载
notso411over 1 year ago
What if you assigned each user a unique ID, used this to determine the user session data and persisted this data in a server that was accessible by both web browsers. You could authenticate yourself against this user id by means of a secret only this user knows<p>It sounds a bit radical but it may work!
evbogueover 1 year ago
If you rewrite the server in Deno you can remoteStorage the data in localStorage!<p><a href="https:&#x2F;&#x2F;docs.deno.com&#x2F;runtime&#x2F;manual&#x2F;runtime&#x2F;web_storage_api" rel="nofollow">https:&#x2F;&#x2F;docs.deno.com&#x2F;runtime&#x2F;manual&#x2F;runtime&#x2F;web_storage_api</a>
toomuchtodoover 1 year ago
Cookies or passkeys? Seems very complex when you can use something simply to track state and identity. Passkeys sync across cloud storage, for example, even if you’re using a uuid as the username.
评论 #38973648 未加载
novoreorxover 1 year ago
I think you should give an API specification so that people don’t bother using public API or hosting another service could implement it directly in the existing backend.
valskover 1 year ago
I like this but umm yeah I can roll my own pretty easily. If you had a simple auth solution built in I&#x27;d use it!
评论 #38983697 未加载
shunyaekamover 1 year ago
What is special with the server? I was surprised you offered a community-hosted server.<p>An OpenAPI spec should be enough, right?
评论 #38974864 未加载
lxeover 1 year ago
So, just a UUID to authenticate? How do you recover&#x2F;reset in case it gets lost?
评论 #38974878 未加载
thatwasunusualover 1 year ago
&gt; let&#x27;s say you want to show a welcome modal to all new users that sign up for your product.<p>Not sure if this is a good example; how many users sign up for the same product multiple times?
评论 #38973879 未加载
thih9over 1 year ago
Can this be treated as tracking or storing information about the user in the context of data regulations (like gdpr and similar)?
评论 #38976027 未加载
SushiHippieover 1 year ago
Not to be confused with <a href="https:&#x2F;&#x2F;remotestorage.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;remotestorage.io&#x2F;</a>
评论 #39004641 未加载
评论 #38975538 未加载
vidarhover 1 year ago
The name Remotestorage is already used for a protocol for portable user-controlled storage. See e.g. Remotestorage.io.
评论 #38974412 未加载
airtonixover 1 year ago
how is this different from remotestorage.io ?