Skip to content
← Server State
Edit Server State
Name
Also known as (comma separated)
Brief definition
Data originating from a backend/API.
Notes
Tier
Core
Useful
Reference
Deleted
Controls schema (JSON array)
[ { "id": "resourceName", "type": "text", "label": "Resource", "default": "/api/orders" }, { "id": "freshness", "type": "select", "label": "Freshness", "default": "fresh", "options": [ "fresh", "refetching", "stale" ] }, { "id": "accent", "type": "color", "label": "Accent colour", "default": "#BFD9F2", "presets": [ "#BFD9F2", "#A8E6C1", "#F5C2E0", "#D9C8F0", "#E8A020", "#241430" ] }, { "id": "showOwner", "type": "toggle", "label": "Show source-of-truth note", "default": true } ]
Templates (JSON object keyed by format)
{ "html": "<div class=\"srvst srvst--{{freshness}}\">\n <div class=\"srvst__flow\">\n <span class=\"srvst__node srvst__node--server\" style=\"--a:{{accent}};\">Server</span>\n <span class=\"srvst__arrow\" aria-hidden=\"true\">→</span>\n <span class=\"srvst__node srvst__node--client\">Client copy</span>\n </div>\n <p class=\"srvst__key\">{{resourceName}}</p>\n <p class=\"srvst__status srvst__status--fresh\">Fresh — matches the server exactly</p>\n <p class=\"srvst__status srvst__status--refetching\">Refetching — showing the old copy while the new one loads</p>\n <p class=\"srvst__status srvst__status--stale\">Stale — the server has moved on since this copy was cached</p>\n {{#if showOwner}}<p class=\"srvst__note\">The client copy is never the source of truth — the server always is.</p>{{/if}}\n</div>\n<style>\n.srvst { font: 12px/1.5 system-ui, sans-serif; color: #241430; background: #FAF7F2; padding: 18px; border-radius: 12px; width: 300px; box-sizing: border-box; }\n.srvst__flow { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }\n.srvst__node { flex: 1; text-align: center; padding: 10px 4px; border-radius: 8px; background: #24143010; font-size: 11px; font-weight: 700; }\n.srvst--fresh .srvst__node--client, .srvst--stale .srvst__node--client { background: var(--a); }\n.srvst--refetching .srvst__node--server, .srvst--refetching .srvst__node--client { background: var(--a); }\n.srvst__arrow { color: #24143060; }\n.srvst__key { margin: 0 0 8px; font: 11px ui-monospace, monospace; color: #24143099; }\n.srvst__status { display: none; margin: 0; font-size: 11px; font-weight: 600; }\n.srvst--fresh .srvst__status--fresh, .srvst--refetching .srvst__status--refetching, .srvst--stale .srvst__status--stale { display: block; }\n.srvst__note { margin: 10px 0 0; font-size: 10px; color: #24143099; }\n</style>", "tailwind": "<div class=\"srvsttw srvsttw--{{freshness}} font-sans text-[#241430] bg-[#FAF7F2] p-4.5 rounded-xl w-[300px] box-border\">\n <div class=\"flex items-center gap-2 mb-2.5\">\n <span class=\"srvsttw__server flex-1 text-center py-2.5 px-1 rounded-lg bg-[#24143010] text-[11px] font-bold\" style=\"--a:{{accent}};\">Server</span>\n <span class=\"text-[#24143060]\" aria-hidden=\"true\">→</span>\n <span class=\"srvsttw__client flex-1 text-center py-2.5 px-1 rounded-lg bg-[#24143010] text-[11px] font-bold\">Client copy</span>\n </div>\n <p class=\"m-0 mb-2 font-mono text-[11px] text-[#24143099]\">{{resourceName}}</p>\n <p class=\"srvsttw__status srvsttw__status--fresh hidden m-0 text-[11px] font-semibold\">Fresh — matches the server exactly</p>\n <p class=\"srvsttw__status srvsttw__status--refetching hidden m-0 text-[11px] font-semibold\">Refetching — showing the old copy while the new one loads</p>\n <p class=\"srvsttw__status srvsttw__status--stale hidden m-0 text-[11px] font-semibold\">Stale — the server has moved on since this copy was cached</p>\n {{#if showOwner}}<p class=\"mt-2.5 m-0 text-[10px] text-[#24143099]\">The client copy is never the source of truth — the server always is.</p>{{/if}}\n</div>\n<style>\n.srvsttw--fresh .srvsttw__client, .srvsttw--stale .srvsttw__client { background: var(--a); }\n.srvsttw--refetching .srvsttw__server, .srvsttw--refetching .srvsttw__client { background: var(--a); }\n.srvsttw--fresh .srvsttw__status--fresh, .srvsttw--refetching .srvsttw__status--refetching, .srvsttw--stale .srvsttw__status--stale { display: block; }\n</style>", "react": "export function ServerState({\n resourceName = \"{{resourceName}}\",\n freshness = \"{{freshness}}\",\n accent = \"{{accent}}\",\n showOwner = {{showOwner}},\n}) {\n const statuses = {\n fresh: \"Fresh \\u2014 matches the server exactly\",\n refetching: \"Refetching \\u2014 showing the old copy while the new one loads\",\n stale: \"Stale \\u2014 the server has moved on since this copy was cached\",\n };\n const node = (active) => ({ flex: 1, textAlign: \"center\", padding: \"10px 4px\", borderRadius: 8, fontSize: 11, fontWeight: 700, background: active ? accent : \"#24143010\" });\n return (\n <div style={{ font: \"12px/1.5 system-ui, sans-serif\", color: \"#241430\", background: \"#FAF7F2\", padding: 18, borderRadius: 12, width: 300, boxSizing: \"border-box\" }}>\n <div style={{ display: \"flex\", alignItems: \"center\", gap: 8, marginBottom: 10 }}>\n <span style={node(freshness === \"refetching\")}>Server</span>\n <span style={{ color: \"#24143060\" }}>→</span>\n <span style={node(freshness !== \"refetching\")}>Client copy</span>\n </div>\n <p style={{ margin: \"0 0 8px\", fontFamily: \"ui-monospace, monospace\", fontSize: 11, color: \"#24143099\" }}>{resourceName}</p>\n <p style={{ margin: 0, fontSize: 11, fontWeight: 600 }}>{statuses[freshness]}</p>\n {showOwner && <p style={{ margin: \"10px 0 0\", fontSize: 10, color: \"#24143099\" }}>The client copy is never the source of truth — the server always is.</p>}\n </div>\n );\n}" }
Save
History