Settings Tutorial

This tutorial will show you how to manage settings, and how to create your own settings adapter.

The Settings adapter handles settings requests.



const settings = core.make('osjs/settings');

// Saves all settings;

// Loads all settings

// Gets a settings object from a namespace

// Sets a settings object to a namespace
settings.set('some/namespace', 'key', 'value')


An application is given the namespace osjs/application/{name} (where the name is taken from your application metadata):

import {name as applicationName} from './metadata.json';

OSjs.make('osjs/packages').register(applicationName, (core, args, options, metadata) => {
  // Default settings
  options.settings = {
    foo: 'bar'

  const proc = core.make('name', {options, args, metadata});

  // Get a setting
  console.log(; // => "bar"

  // Set a setting = 'baz';

  // Save settings
    .then(() => console.log('done'));

  return proc;

Custom Settings Adapter

To set up your adapter, see the settings guide.

To generate a new adapter using the example via CLI run npm run make:settings.

For general information about development see development article.


const myAdapter = (core, options) => ({
  save: values => {
    // Create your own request here with 'values' settings
    return Promise.resolve(true);

  load: () => {
    // Create your own request here and return settings
    return Promise.resolve({})

export default myAdapter;


module.exports = (core, options) => ({
  save: (req, res) => {
    // req.body has all settings from client
    return Promise.resolve(true);
  load: (req, res) => {
    // return all settings for user here
    return Promis.resolve({});
OS.js Web Desktop - © Anders Evenrud <>

results matching ""

    No results matching ""