Storage
A persistent key-value store for your automation scripts.
Storage is a persistent key-value store scoped to your organization. Your scripts can use it to remember data between executions.
What is it?
Each organization has its own storage — a simple key-value database where keys are strings and values are arbitrary JSON. Storage persists across all script executions, making it perfect for:
- Counters — subscriber count, command usage
- State tracking — current scene, last greeted user
- Configuration — custom responses, thresholds
- User data — points, preferences
Using storage in scripts
Inside your action code, import storage from "rawtoh":
Read a value
import { storage } from "rawtoh"
const count = await storage.get("sub_count")
// Returns the stored value, or undefined if the key doesn't existWrite a value
import { storage } from "rawtoh"
await storage.set("sub_count", 42)
await storage.set("last_user", { name: "alice", time: Date.now() })
// Values can be any JSON-serializable dataPractical example
import { event, module, storage } from "rawtoh"
// Track how many times each user has used a command
const user = event.payload.user_name
const key = `cmd_count:${user}`
let count = await storage.get(key) || 0
count++
await storage.set(key, count)
await module("twitch").request("chat.say", {
message: `@${user}, you've used this command ${count} times!`
})Managing storage in the UI
You can also view and edit storage entries directly from the dashboard. Go to the Storage page in the sidebar to:
- Browse all key-value pairs
- Create new entries
- Edit existing values with the JSON editor
- Delete entries
This is useful for setting up initial configuration, debugging script state, or manually adjusting values.
Tips
- Use prefixes to namespace your keys —
points:alice,config:greeting,state:current_scene. - Values are JSON — you can store objects and arrays, not just strings and numbers.
- Storage is organization-scoped — all scripts in the same organization share the same storage, which makes it easy to share data between automations.
- Reads are fast — don't hesitate to use storage in frequently-triggered actions.