Demo and sandbox mode
Demo mode lets visitors try editing without signing in. Use it for disposable
examples, not for a production publishing workflow. It differs from the
marketing site’s /demo, which uses a browser-only localStorage simulation.
Requirements
Section titled “Requirements”Use an adapter with makeSessionOverlay() and an upload handler with
makeSessionWrapper(). The bundled Cloudflare KV and Durable Object storage
adapters support session overlays; r2Uploads() supplies upload quotas.
R2 sandbox quota tracking also needs a KV binding (CMS_KV by default,
or the quotaBinding option), even when content uses Durable Objects.
See Cloudflare setup.
Filesystem and Markdown storage do not support demo session overlays. If isolation is unavailable, CaretCMS disables demo editor access rather than letting anonymous visitors modify the shared store.
Enable a sandbox
Section titled “Enable a sandbox”- Deploy a dedicated demo using supported Cloudflare storage and R2 uploads.
- Set
CARET_DEMO_MODE = "true"in your Worker’s variables. - Seed the base content using your chosen adapter. Each visitor starts from that content and sees only their own overlay changes.
The public repository’s demo example shows a complete application. KV fallback data is not an automatic migration into Durable Object storage.
Session lifetime
Section titled “Session lifetime”Caret sets a caret_demo_session cookie with a two-hour sliding lifetime.
Writes and deletions affect the session overlay, not the canonical base.
Closing a tab does not reliably reset the session: the cookie is shared
across same-origin tabs. To start fresh, clear that site’s demo cookie or use
a separate browser profile. Sandbox content has no persistence guarantee.
Upload quotas
Section titled “Upload quotas”R2 demo uploads default to 5 MiB per file and 25 MiB per session:
import { r2Uploads } from '@caretcms/cloudflare';
const uploads = r2Uploads({ binding: 'CMS_R2', publicBaseUrl: 'https://images.example.com', sandboxPerFileBytes: 5 * 1024 * 1024, sandboxPerSessionBytes: 25 * 1024 * 1024,});Pass uploads to caret({ uploads }). The R2 bucket must have a working public
URL. These additional sandbox quotas do not replace normal file-type and upload
validation. The quota counter serializes within a Worker isolate; treat it as a
soft sandbox limit, not a hard billing cap across a distributed fleet.
If the UI asks you to close the tab after reaching the session quota, clear the demo cookie instead; closing the tab alone may retain it.
Use authentication and permissions for real editorial access.