Skip to content

Storing data

nari.set(key, value) and nari.get(key) store JSON values for your plugin:

local plays = (nari.get("plays") or 0) + 1
nari.set("plays", plays)
nari.set("old_key", nil) -- removes a key
  • The data is shared by main.lua and every thread of the plugin.
  • It survives restarts and updates, and is deleted when the plugin is uninstalled.
  • It lives in user://plugin_data/<id>.json. Writes are atomic, and if the file is ever corrupted nari.set raises an error instead of overwriting it.

Passwords, tokens and keys go in private storage:

nari.set("refresh_token", token, { private = true })
local token = nari.get("refresh_token")

Private values are encrypted (AES-256-GCM) in user://plugin_data/<id>.private with a key that never leaves the device:

System Where the key is kept
Android The Keystore
Windows Protected with the user account (DPAPI)
macOS The Keychain
Linux The system keyring (KWallet, GNOME Keyring or the Flatpak secret portal), or a file only the user can read when there’s no keyring

Copying the file to another device doesn’t open it. nari.get reads private and plain values the same way, a private key stays private when it’s set again, and nari.set(key, nil) removes it.