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

Keychain

Securely store sensitive data like tokens, passwords, and API keys using the platform’s secure storage. Every snippet below is excerpted from docs/examples/system/snippets.ts — CI links it on every PR.

Usage

keychainSave("api_token", "sk-...")
const token = keychainGet("api_token")
keychainDelete("api_token")
console.log(`token length: ${token.length}`)

The free-function API is keychainSave(key, value), keychainGet(key) (returns the stored string, or an empty string if the key isn’t present), and keychainDelete(key).

Platform Storage

PlatformBackend
macOSSecurity.framework (Keychain)
iOSSecurity.framework (Keychain)
AndroidAndroid Keystore
WindowsWindows Credential Manager (CredWrite/CredRead/CredDelete)
Linuxlibsecret
WeblocalStorage (not truly secure)

Web: The web platform uses localStorage, which is not encrypted. For web apps handling sensitive data, consider server-side storage instead.

Next Steps