# Syncing Addon simple-prefs

**URL:** <https://discourse.mozilla.org/t/syncing-addon-simple-prefs/9326>\
**Category:** Development\
**Created:** [June 20, 2016, 9:37am UTC](https://discourse.mozilla.org/t/syncing-addon-simple-prefs/9326 "2016-06-20T09:37:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon31560143](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@anon31560143](https://discourse.mozilla.org/u/anon31560143)\
**Post date:** [June 20, 2016, 9:37am UTC](https://discourse.mozilla.org/t/syncing-addon-simple-prefs/9326/1 "2016-06-20T09:37:47Z")

</div>

I would like to sync prefs of my Firefox addon using **require(‘sdk/preferences/service’)**.

Here my non-working trial:  
**lib/main.js:**  
const  
addonid = require(‘sdk/self’).id,  
simprefs = require(‘sdk/simple-prefs’)  
service = require(‘sdk/preferences/service’)  
;  
service.set(‘services.sync.prefs.sync.extensions.’ + addonid + ‘.syncy’, true);

```
 simprefs.on('1', function() {
       simprefs.prefs["syncy"] = simprefs.prefs["1"];
});

```

**package.json:**  
{  
“title”: “Test”,  
“name”: “test”,  
“author”: “devname”,  
“version”: “1.0.0”,  
“main”: “lib/main.js”,  
“engines”: {“firefox”: “\>=38.0a1”,“fennec”: “\>=38.0a1”},  
“license”: “MPL-2.0”,  
“id”: "test@devname.org",  
“permissions”: {“private-browsing”: true},  
“dependencies”: [“addon-kit”],  
“preferences”: [{  
“title”: “Color 1”,  
“type”: “color”,  
“value”: “#000000”,  
“name”: “1”  
}]}

So, when in the Addon-Manager I set pref 1 to color #777777 then pref  
syncy will get the same value (visible on the about:config page).

When I use 2 Firefox profiles and register with Mozilla for syncing and  
install this add-on on each of them I expect that changing this value on  
one profile will change it on the other (so the setting on about:config  
-\> extensions.test@devname.org.syncy) - but it doesn’t.

What do I do wrong?

---

<div class="post-metadata">

**Author:** ![noitidart](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@noitidart](https://discourse.mozilla.org/u/noitidart)\
**Post date:** [June 20, 2016, 9:49am UTC](https://discourse.mozilla.org/t/syncing-addon-simple-prefs/9326/2 "2016-06-20T09:49:01Z")

</div>

Have you done a lot of the work with SDK? Because the sync mechansim for WebExtension API is much more reliable.

---

<div class="post-metadata">

**Author:** ![anon31560143](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@anon31560143](https://discourse.mozilla.org/u/anon31560143)\
**Post date:** [June 20, 2016, 9:59am UTC](https://discourse.mozilla.org/t/syncing-addon-simple-prefs/9326/3 "2016-06-20T09:59:46Z")

</div>

Yes, only with SDK - can you post me a link for how to use this WE API? Thank you
