Skip to content

Conversation

@V3RON
Copy link
Contributor

@V3RON V3RON commented Jan 7, 2026

Description

Adds a shared storage API to @rozenite/plugin-bridge that enables plugins to synchronize state between the DevTools panel (host) and the React Native app (device). The storage persists data in the browser's localStorage on the host side and automatically synchronizes with connected devices.

Context

This feature was implemented using a factory pattern that returns different implementations for the host (DevTools panel) and device (React Native app):

  • Host implementation: Acts as the source of truth, loads from and saves to localStorage with the key format rozenite-storage-${pluginId}. When a device connects, it either adopts the device's defaults (if no persisted data exists) or sends the persisted data to the device.

  • Device implementation: Starts with provided defaults, sends an rozenite-storage-init message upon connection, and updates its in-memory state when receiving rozenite-storage-sync or rozenite-storage-update messages from the host.

The communication protocol uses three custom event types:

  • rozenite-storage-init: Device → Host (includes default values)
  • rozenite-storage-sync: Host → Device (full state synchronization)
  • rozenite-storage-update: Host → Device (individual key updates)

The React hook (useRozeniteSharedStorage) supports two modes:

  • Default mode: Returns defaults immediately, updates after sync (useful for non-critical UI)
  • Ensured synchronization mode: Returns null until first sync completes (prevents UI flickering for critical data)

Testing

  • Manual testing in the playground app

@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
rozenite Ready Ready Preview, Comment Jan 7, 2026 9:02am

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