@mocanvas/editor · function

useCurrentUser

declare function useCurrentUser({ userPreferences, setUserPreferences }: UseCurrentUserOptions): CurrentUser

Adapt host-owned preferences into the CurrentUser the editor takes.

The point is control: the editor reads preferences through a signal, but the value in that signal is whatever the host last rendered, and every write the editor makes goes back out through the host's setter. Nothing is persisted and no global storage key is touched — so a host that decides, say, the colour scheme cannot be overruled by a setting some other canvas left behind on this origin.

The returned object is identity-stable, so passing it as a prop does not remount the editor.

The integrator exposes this as useTldrawCurrentUser for tldraw-shaped call sites.

Mentioned here

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.