Skip to content

Add per-client localStorage API - #756

Merged
brentyi merged 5 commits into
viser-project:mainfrom
Evanston09:local-storage
Aug 12, 2026
Merged

Add per-client localStorage API#756
brentyi merged 5 commits into
viser-project:mainfrom
Evanston09:local-storage

Conversation

@Evanston09

Copy link
Copy Markdown
Contributor
  • Add client.local_storage methods for reading and writing local storage values
  • Add client/server messages for set, get, remove, and clear operations
  • Document LocalStorageHandle
  • Add a Playwright test

@brentyi

brentyi commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Evanston09! Are you able to share what you're using this for?

@Evanston09

Copy link
Copy Markdown
Contributor Author

Hello! I’m building a 5-axis 3D-printer slicer with Viser, and I’d like to persist a few machine-specific settings in the browser across sessions.

brentyi added 3 commits August 6, 2026 23:25
…semantics with get_render

Keys written via client.local_storage are namespaced under a
"viser-user:" prefix in the browser, and clear() only removes prefixed
keys. This prevents a viser server from reading or wiping localStorage
state that other applications keep on a shared origin (e.g. several
statically-hosted clients under one site). The prefix is applied
client-side; the Python API continues to take bare key names. An e2e
test covers the isolation behavior.

get_item's failure handling now matches get_render(): None strictly
means the key is absent, a disconnect is detected promptly (same 0.1s
poll against _connected_clients) and raises RuntimeError, blocked
storage access raises RuntimeError, and timeout is opt-in -- None
(default) waits indefinitely, while a set timeout raises TimeoutError
when exceeded.
@brentyi
brentyi merged commit 0971adc into viser-project:main Aug 12, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants