Skip to main content
Solved

Figma clientStorage and Svelte store sync

  • March 9, 2023
  • 1 reply
  • 458 views

Poora

How would one go about synchronizing the Figma clientStorage and a Svelte store? I would like to update the svelte store on plugin launch to match the data in the clientStorage. And then before closing the plugin I would like to save all the svelte store data onto the clientStorage again
Any suggestions or examples of plugins that do that?

Best answer by Stephane_Popout

I don’t have examples of plugins doing that but here is what I would do:

  1. For the initial retrieval:
    1. On the svelte app load, send an event to the figma backend asking for the figma clientstorage
    2. Return the figmaclient storage to the front
    3. store it in your svelte store
  2. For the saving before closing
    1. After every update of your store on svelte, you should update the figma store therefore when the user close the plugin it’s already saved
    2. Or, you can listen to the event close and do your saving before closing but it’s not recommended on | Plugin API
View original
This topic has been closed for replies.

1 reply

Stephane_Popout

I don’t have examples of plugins doing that but here is what I would do:

  1. For the initial retrieval:
    1. On the svelte app load, send an event to the figma backend asking for the figma clientstorage
    2. Return the figmaclient storage to the front
    3. store it in your svelte store
  2. For the saving before closing
    1. After every update of your store on svelte, you should update the figma store therefore when the user close the plugin it’s already saved
    2. Or, you can listen to the event close and do your saving before closing but it’s not recommended on | Plugin API

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings