I want to create a global instance of GunDB so that it only initializes once on the client side and I could then use it on any island.
I tried in index.tsx to simply add const gun = Gun() and send props to the island, the only problem is that then the island component does not see the Gun instance, which is normal because the Gun instance is initialized on the server side and not the client side.
In theory, it only needs a global context on the client side. Something like createContext() in react.
Fresh v1.1 adds Preact Signals support.
Preact Signals:
You can create a module that exports a signal for your global
Guninstance:Then you can import this in any interactive island module to use it both server-side and client-side: