Skip to main content

setSharedData

Description

Stores in-memory data that is shared globally while the app runs.

Any page or script can read the stored data with $app.getSharedData(key) for as long as the app is running. The data disappears when the app exits (non-persistent).

Pass null as data to delete that key.

Parameters

ParameterTypeDescription
sharedKeyStringKey name that identifies the data
datadynamicValue to store. null deletes the key

Returns

void

Notes

  • The data lives only in the app process memory and resets when the app restarts.
  • Every page shares the same memory map, so this is a good fit for passing data between pages.
  • Use $app.setStoreData() when you need persistent storage.
  • To change an App Variable defined in Studio, use $app.setVar().
  • No type restriction on values — strings, numbers, objects, and arrays all work.

Example

// Store user info globally after login
$app.setSharedData("currentUser", { id: 1, name: "홍길동", role: "admin" });

// Read it from another page
var user = $app.getSharedData("currentUser");
console.log(user.name); // "홍길동"

// Delete the key (on logout)
$app.setSharedData("currentUser", null);

setSharedData vs setStoreData vs setVar comparison

ItemsetSharedDatasetStoreDatasetVar
Storage locationApp process memoryDisk (LucyStorage)App Variable system (LucyVarMngr)
PersistenceLost when the app exitsKept after the app restartsLost when the app exits
How it's definedAny key you choose in codeAny key you choose in codeMust be predefined in Studio
Read function$app.getSharedData(key)$app.getStoreData(key)$app.getVar(name)
How to deletePass a null valuePass a null valueValue changes only
Main useTemporary data sharing between pagesPersistent storage for user settings, login tokens, and moreControlling App Variables wired to the Studio UI
SpeedFast (memory)Relatively slow (disk I/O)Fast (memory)

When to use which

  • Session data, passing values between pagessetSharedData — fast and simple, cleared automatically when the app exits
  • Settings, login state, favoritessetStoreData — when values must survive an app restart
  • Updating Studio UI variablessetVar — only variables declared in advance in Studio can change
  • $app.getSharedData(sharedKey)
  • $app.setStoreData(key, data)
  • $app.getStoreData(key)
  • $app.setVar(appVarName, data)
  • $app.getVar(appVarName)