Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Preferences

Store and retrieve user preferences using the platform’s native storage.

Usage

import { preferencesSet, preferencesGet } from "perry/system";

// Store a preference
preferencesSet("username", "perry");
preferencesSet("fontSize", "14");
preferencesSet("darkMode", "true");

// Read a preference
const username = preferencesGet("username");  // "perry"
const fontSize = preferencesGet("fontSize");  // "14"

Values are stored as strings. Convert numbers and booleans as needed:

preferencesSet("count", String(42));
const count = Number(preferencesGet("count"));

Platform Storage

PlatformBackend
macOSNSUserDefaults
iOSNSUserDefaults
AndroidSharedPreferences
WindowsWindows Registry
LinuxGSettings / file-based
WeblocalStorage

Preferences persist across app launches. They are not encrypted — use Keychain for sensitive data.

Next Steps